成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

vb.net校驗和 vbnet byval

VB.NET如何對輸入的數(shù)據(jù)進行合法性檢驗,過濾不合法的數(shù)據(jù)代碼

合法性校驗有很多方法,要視情況而定,比如說可以用正則表達式,如果是數(shù)字,除了正則表達式,也可以用諸如TryParse這種方法。

10年積累的成都做網(wǎng)站、網(wǎng)站設計經(jīng)驗,可以快速應對客戶對網(wǎng)站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡服務。我雖然不認識你,你也不認識我。但先做網(wǎng)站設計后付款的網(wǎng)站建設流程,更有定海免費網(wǎng)站建設讓你可以放心的選擇與我們合作。

vb.net 點擊一個叫button1的按鈕 用COM1發(fā)送(接收) 假設八位數(shù)據(jù)位,有奇偶校驗位

這是我的簡單串口代碼:

Dim a As Integer

Dim b As Variant

Private Sub u_Click()

Text1.Text = "請先設置波特率與COM口?。?!"

End Sub

Private Sub Cbo1_Click()

On Error GoTo blak '打開串口發(fā)生錯誤,提示信息

If MSComm1.PortOpen = True And a = 1 Then

MSComm1.PortOpen = False '必須先關閉端口,再對端口進行設置

MSComm1.CommPort = cbo1.ListIndex + 1 '端口號從0開始,必須加1

Else '有必要

MSComm1.CommPort = cbo1.ListIndex + 1

End If '注釋的必須有,為第二次切換做準備,否則第二次換COM口會出問題

Exit Sub

blak:

MsgBox "串口不存在或被占用!", vbOKOnly, "提示信息" '必須是這種格式

End Sub

Private Sub Cbo2_Click() '單擊事件,不是change事件

MSComm1.Settings = 1200 * 2 ^ cbo2.ListIndex "n,8,1" '設置端口的波特率,連接符前后必須空一格

End Sub

Private Sub cmd1_Click()

a = a + 1

If a = 1 Then

cmd1.Caption = "關閉串口"

cbo1.Enabled = False

MSComm1.PortOpen = True '打開串口

ElseIf a = 2 Then

cmd1.Caption = "打開串口"

cbo1.Enabled = True

MSComm1.PortOpen = False '關閉串口

a = 0

End If

End Sub

Private Sub cmd2_Click()

Text1.Text = "" '清空接收區(qū)

Text2.SetFocus

End Sub

Private Sub cmd3_Click()

Text2.Text = "" '清空發(fā)送區(qū)

Text2.SetFocus

End Sub

Private Sub cmd4_Click()

Dim d As Integer

Dim e(0) As Byte 'outbyte 輸出字符

d = Val(Text2.Text)

e(0) = CByte(d)

MSComm1.OutBufferCount = 0 '清除發(fā)送緩沖區(qū)

MSComm1.Output = e '此命令執(zhí)行一次發(fā)送8字節(jié)

End Sub

Private Sub Form_Load()

cbo1.ListIndex = 0

cbo2.ListIndex = 0

MSComm1.OutBufferCount = 0

MSComm1.InBufferCount = 0

End Sub

Private Sub MSComm1_OnComm()

Select Case MSComm1.CommEvent '返回最近的通信過程

Case comEvReceive '接受的數(shù)據(jù)

c: b = MSComm1.Input

If Option1.Value = True Then

Text3.Text = Text1.Text Hex(b(0)) '首次不行,因為有字符

Text1.Text = Text3.Text " " '轉(zhuǎn)換一下

ElseIf Option2.Value = True Then

Text1.Text = Text1.Text b ""

End If

If MSComm1.InBufferCount 0 Then 'mscomm1.InBufferCount是緩沖區(qū)的數(shù)據(jù)數(shù)

GoTo c

End If

End Select

End Sub

Private Sub Option1_Click()

MSComm1.InputMode = comInputModeBinary '接收方式,十六進制

End Sub

Private Sub Option2_Click()

MSComm1.InputMode = comInputModeText '接收方式,字符格式

End Sub

Private Sub Text1_Change()

Text1.SelStart = Len(Text1.Text)

End Sub

VB.NET登陸界面。要驗證登錄用戶名和密碼是否正確。登陸后有管理員和普通用戶權限判斷。管理員只能登錄一

將用戶名,密碼,用戶類型存在數(shù)據(jù)庫中,登陸時比較輸入的值是否與數(shù)據(jù)庫相同即可。

VB.Net 怎么驗證 SQL2008 數(shù)據(jù)庫的ID與密碼

基礎類庫:

Imports Microsoft.VisualBasic

'執(zhí)行Access語句的封裝類。

Public Class AccessExecClass

Private conn As Data.OleDb.OleDbConnection

Private cmd As Data.OleDb.OleDbCommand

'創(chuàng)建類對象,并連接到數(shù)據(jù)庫。

Sub New()

If openAccess Then

Else

msgbox("open Access Fail.")

End If

End Sub

'創(chuàng)建類對象,并連接到數(shù)據(jù)庫。 '輸入帶目錄名稱的數(shù)據(jù)庫文件名稱:dbFileName,例如:“\DB數(shù)據(jù)庫\企業(yè)數(shù)據(jù)庫.aspx”

Sub New(ByVal dbFileName As String)

If OpenAccess(dbFileName) Then

Else

MsgBox("open Access Fail.")

End If

End Sub

Function OpenAccess() As Boolean

OpenAccess = False

'檢驗用戶的帳號密碼是否正確

Dim provider As String '= ConfigurationManager.ConnectionStrings("ConnectionString").ProviderName

provider = "Provider=Microsoft.Jet.OLEDB.4.0"

Dim database As String

database = "Data Source=" System.Web.HttpContext.Current.Server.MapPath("\數(shù)據(jù)庫.aspx") ";Persist Security Info=true"

conn = New Data.OleDb.OleDbConnection(provider ";" database)

conn.Open()

OpenAccess = True

End Function

Function OpenAccess(ByVal dbFileName As String) As Boolean

OpenAccess = False

'檢驗用戶的帳號密碼是否正確

Dim provider As String '= ConfigurationManager.ConnectionStrings("ConnectionString").ProviderName

provider = "Provider=Microsoft.Jet.OLEDB.4.0"

Dim database As String

database = "Data Source=" System.Web.HttpContext.Current.Server.MapPath(dbFileName) ";Persist Security Info=true"

conn = New Data.OleDb.OleDbConnection(provider ";" database)

conn.Open()

OpenAccess = True

End Function

'關閉數(shù)據(jù)庫。

Sub CloseAccess()

cmd = Nothing

conn.Close()

End Sub

'執(zhí)行一條Access語句,執(zhí)行成功就返回True。

Function ExecAccessString(ByVal AccessStr As String) As Boolean

cmd = New Data.OleDb.OleDbCommand(AccessStr, conn)

cmd.ExecuteNonQuery()

'Dim aa As Data.OleDb.OleDbDataReader = cmd.ExecuteReader

ExecAccessString = True

End Function

'返回讀取到的數(shù)據(jù),注意是用地址傳遞方式返回

Sub ExecAccessString(ByVal AccessStr As String, ByRef AccessReader As Data.OleDb.OleDbDataReader)

cmd = New Data.OleDb.OleDbCommand(AccessStr, conn)

cmd.ExecuteNonQuery()

AccessReader = cmd.ExecuteReader

End Sub

End Class

登陸代碼:

Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click

Dim wl As New WebLog '用戶登錄記錄開始,僅對購買了Log 功能的用戶,才開放此功能,否則不會實際記錄Log

Dim sql As String

Dim aDB As New AccessExecClass

Dim mypw As String

Label1.Visible = False

Label2.Visible = False

Label3.Visible = False

Label4.Visible = False

'沒有輸入時,不能進行登陸

If TextBox1.Text = "" Then

Label1.Visible = True

Return

End If

If TextBox2.Text = "" Then

Label2.Visible = True

Return

End If

If TextBox3.Text = "" Then

Label3.Visible = True

Return

End If

If TextBox3.Text = TextBox4.Text Then

Else

Label3.Visible = True

Return

End If

Dim iRnd As Integer = Rnd(10) * 100

TextBox3.Text = ""

TextBox4.Text = iRnd.ToString

'Dim iRnd As Integer = Rnd(10) * 100

'注意:此處需要加入防止注入分析,包含'的肯定是特別語句,講拒絕.

If TextBox1.Text.IndexOf("'") 0 Or TextBox2.Text.IndexOf("'") 0 Then

TextBox1.Text = "不能輸入非法字符,將強制清空"

TextBox2.Text = ""

Else

Dim pw As New MD5EnCode(13, 19) ' '2次加密

sql = "select 權限組號,ID , 密碼 from 編輯人數(shù)據(jù) where 編輯姓名='" + TextBox1.Text + "'"

Dim aa As Data.OleDb.OleDbDataReader '= cmd.ExecuteReader

aDB.ExecAccessString(sql, aa)

If aa.Read() Then

'密碼正確()

'sql = aa(2)'需要特別注意:只能單向解密,不能直接轉(zhuǎn)換

mypw = pw.simDeCode(pw.simDeCode(aa(2)))

If TextBox2.Text = mypw Then

Session("LOGIN_Name") = TextBox1.Text '設置登錄后的用戶名稱

Session("Login_Group") = aa(0) 'cmd.ExecuteScalar '設置登錄后的權限級別

Session("Login_ID") = aa(1) 'cmd.ToString

'cmd = Nothing

'conn.Close()

Call wl.NewLog("登錄", "管理員成功登錄")

Response.Redirect("../WebManages/Default.ASPX")

Else

'密碼錯誤()

sql = sql.Replace("'", "【單引號】")

sql = sql.Replace(",", "【逗號】")

Call wl.NewLog("登錄", "管理員失敗的登錄", TextBox1.Text, sql.Replace("""", "【雙引號】"), "")

Label4.Visible = True

End If

Else

'密碼錯誤()

sql = sql.Replace("'", "【單引號】")

sql = sql.Replace(",", "【逗號】")

Call wl.NewLog("登錄", "管理員失敗的登錄", TextBox1.Text, sql.Replace("""", "【雙引號】"), "")

Label4.Visible = True

End If

End If

End Sub

當前文章:vb.net校驗和 vbnet byval
標題路徑:http://jinyejixie.com/article48/doseehp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站企業(yè)網(wǎng)站制作、商城網(wǎng)站網(wǎng)頁設計公司、網(wǎng)站維護做網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設
甘南县| 蓬莱市| 辉县市| 商丘市| 洪洞县| 名山县| 陕西省| 临漳县| 城口县| 郸城县| 阜宁县| 高雄县| 古浪县| 韶关市| 宝山区| 临城县| 吉隆县| 华蓥市| 东光县| 富蕴县| 嘉禾县| 连州市| 疏勒县| 孝昌县| 南木林县| 吉水县| 屏东市| 阳信县| 阳信县| 鞍山市| 云南省| 邢台市| 开封县| 揭西县| 天峻县| 赤壁市| 平武县| 海晏县| 岳阳县| 元朗区| 游戏|