网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

vb.net记住多个账号 vbnet foreach

VB.net 如何实现记住密码 自动登录

代码如下:

创新互联建站专注为客户提供全方位的互联网综合服务,包含不限于成都做网站、网站设计、外贸营销网站建设、鄄城网络推广、微信小程序、鄄城网络营销、鄄城企业策划、鄄城品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联建站为所有大学生创业者提供鄄城建站搭建服务,24小时服务热线:18980820575,官方网址:www.cdcxhl.com

/// summary

/// 连接到窗体:通过密码保护信息找回密码!

/// /summary

/// param name="sender"/param

/// param name="e"/param

private void lbl_mibao_Click(object sender, EventArgs e)

{

Getbackpwd getbackpwd = new Getbackpwd();

getbackpwd.Show();

}

/// summary

/// 当该窗体加载时从xml文件中读取用户信息并加载到combox的Items中

/// /summary

/// param name="sender"/param

/// param name="e"/param

private void Addresslist_Load(object sender, EventArgs e)

{

XmlTextReader reader = new XmlTextReader(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");

while (reader.Read())

{

//if (reader.LocalName.Equals("Name") || reader.LocalName.Equals("Number"))

if (reader.LocalName.Equals("username"))

{

this.cmbUserName.Items.Add(reader.ReadString());

}

//if (reader.LocalName.Equals("Number"))

//{

// this.label2.Text += reader.ReadString() + "\n";\

//}

}

reader.Close();

}

/// summary

/// 保存用户名到user.xml

/// /summary

//在listcontol上更改SelectedValue时执行从数据库读取密码的事件

private void cmbUserName_SelectedValueChanged(object sender, EventArgs e)

{

string username = cmbUserName.Text.Trim();

string sql = string.Format("select pwd from Admin where Username='{0}'", username);

try

{

SqlCommand command = new SqlCommand(sql, DBHelper.connection);

DBHelper.connection.Open();

SqlDataReader dataReader = command.ExecuteReader();

while (dataReader.Read())

{

txtpwd.Text = (string)dataReader["pwd"];

checkBoxpwd.Checked = true;

}

}

catch

{

MessageBox.Show("数据库操作出错!");

}

finally

{

DBHelper.connection.Close();

}

}

/// summary

/// 记住密码操作

/// /summary

/// param name="sender"/param

/// param name="e"/param

private void checkBoxpwd_Enter(object sender, EventArgs e)

{

bool check = true;

check = checkinput(cmbUserName.Text.Trim());

if ((string)cmbUserName.Text.Trim() == "")

{

MessageBox.Show("请输入用户名", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

cmbUserName.Focus();

}

else

{

if (txtpwd.Text.Trim() == "")

{

MessageBox.Show("请输入密码", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

txtpwd.Focus();

}

else

{

bool isValidUser = false; // 标识是否为合法用户

string message = ""; // 如果登录失败,显示的消息提示

// 如果验证通过,就显示相应的用户窗体,并将当前窗体设为不可见

if (ValidateInput())

{

// 调用用户验证方法

isValidUser = ValidateUser(cmbUserName.Text, txtpwd.Text, ref message);

// 如果是合法用户,显示相应的窗体

if (isValidUser)

{

if (check == true)

{

XmlDocument doc = new XmlDocument();

doc.Load(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");//(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");

XmlElement node = doc.CreateElement("user");

XmlNode xnode = (XmlNode)doc.CreateElement("username");

xnode.InnerText = cmbUserName.Text.Trim();

node.AppendChild(xnode);

doc.DocumentElement.InsertAfter(node, doc.DocumentElement.LastChild);

doc.Save(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");

//doc.Load (@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");

}

}

// 如果登录失败,显示相应的消息

else

{

MessageBox.Show(message, "记住密码失败!", MessageBoxButtons.OK, MessageBoxIcon.Information);

}

}

}

}

}

/// summary

/// 验证当前combox中内容是否已经存在于xml文件中

/// /summary

/// param name="text"/param

/// returns/returns

private bool checkinput(string text)

{

int count;

bool c = true;

for (count = 0; count cmbUserName.Items.Count;count ++ )

{

if (text ==(string )cmbUserName .Items [count])

{

c=false;

}

}

return c;

}

xml文件内容如下:?xml version="1.0" encoding="utf-8"?

person

user

vb.net访问网络数据库如何不把密码保存到本地程序中?

虚拟机上一般有的会附带数据库,有的需要另外花钱购置,然后你在虚拟机上创建一个数据库,把你代码连接数据库的IP等设置,设置到你虚拟机上的地址

求vb.net句柄实例,实现操作其他程序窗口。如我给的例子

Imports System.Text

Imports System.Runtime.InteropServices

Public Class Form1

' 相关API函数声明,注释掉的这里没用到,但是也比较常用吧,这些函数的功能都能搜到。

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr

Private Delegate Function EnumChildProc(ByVal hWnd As IntPtr, ByVal lParam As Integer) As Boolean

Private Declare Function EnumChildWindows Lib "user32.dll" (ByVal hWndParent As IntPtr, ByVal lpEnumFunc As EnumChildProc, ByVal lParam As Integer) As Boolean

Private Declare Auto Function SendMessage Lib "User32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer

'Private Declare Function CheckDlgButton Lib "user32" Alias "CheckDLGButtonA" (ByVal hDlg As IntPtr, ByVal nIDButton As IntPtr, ByVal wCheck As Integer) As Integer

Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As IntPtr, ByVal lpClassName As StringBuilder, ByVal nMaxCount As Integer) As Integer

'Private Declare Function GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (ByVal hwnd As IntPtr, ByVal lpdwProcessId As Long) As Integer

Private Declare Auto Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLength" (ByVal hwnd As IntPtr) As Integer

Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As StringBuilder, ByVal cch As Integer) As Integer

' 相关消息定义,也有没用到的

Const WM_SETTEXT = HC

Const WM_GETTEXT = HD

'Const WM_SETFOCUS = H7

'Const WM_KILLFOCUS = H8

'Const WM_CLOSE = H10

'Const WM_SYSCOMMAND = H112

'Const SC_CLOSE = HF060

'Const SC_MINIMIZE = HF020

Const BM_GETCHECK = HF0

Const BM_SETCHECK = HF1

Const BM_GETSTATE = HF2

Const BM_SETSTATE = HF3

Const BM_SETSTYLE = HF4

Const BM_CLICK = HF5

'Const BM_GETIMAGE = HF6

'Const BM_SETIMAGE = HF7

Const BST_UNCHECKED = O0

Const BST_CHECKED = O1

Const BST_INDETERMINATE = O2

' 储存窗口句柄

Dim WindowHandle As IntPtr

' 储存两个(或者多个)编辑框句柄

Dim EditHandle As New List(Of IntPtr)

Dim EditWindowsText As List(Of String)

' 储存复选框句柄

Dim CheckHandle As IntPtr = 0

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Button1_Click(sender, e)

End Sub

' EnumChildWindows 回调函数,该函数名作为API函数EnumChildWindows 的一个参数

' 该函数实现了枚举各个子窗口,找出编辑框属性的功能

Public Function EnumChildProcC(ByVal hwnd As IntPtr, ByVal lParam As Integer) As Boolean

Dim dwWindowClass As StringBuilder = New StringBuilder(100)

' 获得某一个句柄的类名

GetClassName(hwnd, dwWindowClass, 100)

If dwWindowClass.ToString.Contains("EDIT") Or dwWindowClass.ToString.Contains("Edit") Then     ' 类名包含EDIT的为编辑框

EditHandle.Add(hwnd)                        ' 存储该句柄

End If

' 返回 True 一直枚举完

Return True

End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

WindowHandle = FindWindow(vbNullString, "登陆")

If WindowHandle.ToInt32 = 0 Then

MsgBox("未捕获到窗口" + "登陆")

Return

End If

' 枚举所有主窗口的子窗口(控件),枚举时自动调用回调函数,完成编辑框句柄的获取

EnumChildWindows(WindowHandle, AddressOf EnumChildProcC, 0)

' 寻找复选框

CheckHandle = FindWindowEx(WindowHandle, IntPtr.Zero, vbNullString, "记住密码")

Dim str As New StringBuilder

Dim j As Integer = 0

' 对编辑框文本赋值

For j = 0 To EditHandle.Count - 1

SendMessage(EditHandle(j), WM_SETTEXT, 0, "Text")

'GetWindowText(EditHandle(j), str, 20)

'EditWindowsText.Add(Str.ToString)

'Str.Clear()

Next

If EditHandle.Count = 0 Then

MsgBox("未找到输入框!")

End If        

If CheckHandle.ToInt32  0 Then

'CheckDlgButton(WindowHandle, id, 1)

' 对复选框进行鼠标单击操作

SendMessage(CheckHandle, BM_CLICK, 0, 0)

'SendMessage(CheckHandle, BM_SETCHECK, True, 0)

End If

End Sub

End Class

求大神指点vb.net 怎么取宽带连接的账号呀

.net 取宽带账号和密码的我没,如果你想实现拨号和断网的话 ,我有现成的模块


本文标题:vb.net记住多个账号 vbnet foreach
网页地址:http://bjjierui.cn/article/ddddepj.html

其他资讯