界面文件Form1.Designer.vb :
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>_
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form 重写 Dispose,以清理组件列表。
<System.Diagnostics.DebuggerNonUserCode()>_
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改它。
'不要使用代码编辑器修改它。
<System.Diagnostics.DebuggerStepThrough()>_
Private Sub InitializeComponent()
Me.Command1 = New System.Windows.Forms.Button
Me.Command2 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Command1
'
Me.Command1.Location = New System.Drawing.Point(57, 173)
Me.Command1.Name = "Command1"
Me.Command1.Size = New System.Drawing.Size(75, 23)
Me.Command1.TabIndex = 0
Me.Command1.Text = "显示"
Me.Command1.UseVisualStyleBackColor = True
'
'Command2
'
Me.Command2.Enabled = False
Me.Command2.Location = New System.Drawing.Point(161, 173)
Me.Command2.Name = "Command2"
Me.Command2.Size = New System.Drawing.Size(75, 23)
Me.Command2.TabIndex = 1
Me.Command2.Text = "退出"
Me.Command2.UseVisualStyleBackColor = True
'
'Label1
'
Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Label1.Location = New System.Drawing.Point(43, 31)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(206, 104)
Me.Label1.TabIndex = 3
Me.Label1.Text = "Label1"
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(292, 270)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Command2)
Me.Controls.Add(Me.Command1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
Friend WithEvents Command1 As System.Windows.Forms.Button
Friend WithEvents Command2 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
End Class
代码文件 Form1.vb :
Public Class Form1
Dim clickCount As Int32
Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click
If (clickCount Mod 2) = 0 Then
Label1.Text = "这是我的第一个VB程序"
Command1.Text = "继续"
Else
Label1.Text = "请你赐教,谢谢!"
Command1.Text = "显示"
End If
If (clickCount >0) Then
Command2.Enabled = True
End If
clickCount += 1
End Sub
Private Sub Command2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command2.Click
End
End Sub
End Class
要 *** 作数据库你要说清楚数据库的类型(SQLServer、Access或者其他)
不管简单还是复杂都需要两步:一是连接数据库(即打开数据库),第二查询数据。
连接数据库需要指定数据库类型、
数据库文件位置、登录数据库的用户信息等等。
确定连接信息后相对简单(注意相对而言,有时候反而更复杂)的查询方式是绑定,添加一个ADODC控件,并把文本框(或者标签)的DataSource设置为ADODC控件,DataField设置为数据库的某个字段,不需要写代码就可以查询数据。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)