'代碼來源:代碼街codejie點(diǎn)虐
曲沃ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
'由于在vb點(diǎn)虐 里變量名不區(qū)分大小寫(StuName和stuname是一樣的),所以個別變量名需要修改
'在vb點(diǎn)虐 中,模塊級變量的命名原則是以m_開頭
Public Class Student
Private m_stuNo As String '學(xué)生號字段
Private m_stuName As String '學(xué)生姓名字段
Private m_stuAge As Integer '學(xué)生年齡字段
Private m_stuAddress As String '學(xué)生住址字段
'無參構(gòu)造方法
Public Sub New()
End Sub
'有參構(gòu)造方法
Public Sub New(ByVal stuNo As String, ByVal stuName As String, ByVal stuAge As Integer, ByVal stuAddress As String)
m_stuNo = stuNo
m_stuName = stuName
m_stuAge = stuAge
m_stuAddress = stuAddress
End Sub
'學(xué)生號屬性
Public Property StuNo() As String
Get
Return m_stuNo
End Get
Set(ByVal value As String)
m_stuNo = value
End Set
End Property
'學(xué)生姓名屬性
Public Property StuName() As String
Get
Return m_stuName
End Get
Set(ByVal value As String)
m_stuName = value
End Set
End Property
'學(xué)生年齡屬性
Public Property StuAge() As Integer
Get
Return m_stuAge
End Get
Set(ByVal value As Integer)
m_stuAge = value
End Set
End Property
'學(xué)生住址屬性
Public Property StuAddress() As String
Get
Return m_stuAddress
End Get
Set(ByVal value As String)
m_stuAddress = value
End Set
End Property
End Class
1·綁定數(shù)據(jù)源來進(jìn)行連接
2.用代碼連接
先到數(shù)據(jù)庫建立一個數(shù)據(jù)庫和相應(yīng)的表
連接數(shù)據(jù)庫的代碼:
Dim str As String = "Data Source=服務(wù)器名;Initial Catalog=數(shù)據(jù)庫名;Persist Security Info=True;User ID=;Password="
dim conn As SqlClient.SqlConnection
try
conn = New SqlClient.SqlConnection
conn.ConnectionString = str
conn.Open()
Return True
Catch ex As Exception
MsgBox(ex.ToString)
Return False
End Try
登錄代碼:Dim str As String = "Data Source=服務(wù)器名;Initial Catalog=數(shù)據(jù)庫名;Persist Security Info=True;User ID=;Password="
dim conn As SqlClient.SqlConnection
conn = New SqlClient.SqlConnection
conn.ConnectionString = str
conn.Open()
sqlstr = "Select * From Amd Where AmdName='" TextBox1.Text "' And AmdPwd = '" TextBox2.Text "'"
Dim sqlcmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sqlstr, conn)
Dim dr As SqlClient.SqlDataReader
dr = sqlcmd.ExecuteReader
If dr.Read = True Then '判斷一條記錄為真
kf.Show() '顯示下個窗體
Me.Hide() ’隱藏當(dāng)前窗體
Else
MessageBox.Show("輸入信息有誤!", "提示")
TextBox1.Text = ""
TextBox2.Text = ""
End If
Dim Str(20) As String '20數(shù)據(jù)元素
Dim Text(20) As TextBox
Dim n As Integer = 0
For Each i In Text
i = New TextBox '實(shí)例化
i.Location = New Point(50, n * 20)
Me.Controls.Add(i) '添加窗體
Dim Index As Integer = i.TabIndex '沒index屬性
Str(n) = Index
i.Text = Str(n) 'str數(shù)組值賦值給文本框
n += 1
Next
VB點(diǎn)虐 是解釋型的語言`~他不直接生成*.exe文件`~ 而vb是編譯和解釋都具備的語言他可以直接生成*.exe大部分它是采用編譯的~~~ 什么是解釋~~什么是編譯那? 解釋就好比是吃瓜子吃一個撥一個~~ 而編譯好比是吃瓜子全把它撥了在全吃~~ 所謂的吃瓜子就是也就是把語句變成機(jī)器能讀取的二進(jìn)制你說是全撥了在吃快哪??還是一個撥一個吃快哪??