求一简单的VB程序代码拜托各位大神

求一简单的VB程序代码拜托各位大神,第1张

'添加两个TextBox框 分别设置其MultiLine=True ScrollBars=2 示例代码如下: Private Sub Form_Click() Dim a(1 To 60) As Integer Randomize Timer Print "原数组是:" For i = 1 To 60 a(i) = Int(Rnd * 101 + 100) Print a(i)" "If i Mod 10 = 0 Then Print Next i Print Print "排序后的数组是:" For i = 1 To 59 For j = i + 1 To 60 If a(i) <a(j) Then c = a(i) a(i) = a(j) a(j) = c End If Next j Next i For i = 1 To 60 Print a(i)" "If i Mod 10 = 0 Then Print Next i Print For i = 1 To 60 If a(i) Mod 2 <>0 Then js = js &a(i) &" " Else os = a(i) &" " &os End If Next i js = Trim(js) os = Trim(os) js1 = Split(js, " ") os1 = Split(os, " ") For i = 0 To UBound(js1) Text1.Text = Text1.Text &js1(i) &" " b = b + 1 If b Mod 10 = 0 Then Text1.Text = Text1.Text &vbCrLf Next i For i = 0 To UBound(os1) Text2.Text = Text2.Text &os1(i) &" " c = c + 1 If c Mod 10 = 0 Then Text2.Text = Text2.Text &vbCrLf Next i End Sub

先在程序中加一个Label,名字应该符合VB程序控件命名规范:

lbl<名称>

再加一个Timer控件,名字也要符合命名规范

在窗体代码对话框中打入

Private Sub Form_Load()

On Error Resume Next

Me.Font = "Arial"

Me.FontSize = 24

Me.FontBold = True

<Timer控件名>.Enabled = True

<Timer控件名>.Interval = 1000

End Sub

'下列函数只能二选其一

'是时间显示

Private Sub <Timer控件名>_Timer()

On Error Resume Next

<Label控件名>.Caption = Time

End Sub

'是日期与时间显示

Private Sub <Timer控件名>_Timer()

On Error Resume Next

<Label控件名>.Caption = Now

End Sub

Dim

conn

As

OleDbConnection

Dim

da

As

OleDbDataAdapter

Dim

ds

As

New

DataSet

Dim

ds1

As

New

DataSet

Dim

dt

As

DataTable

Dim

str

As

String

'Dim

cmd

As

OleDbCommand

'Dim

rd

As

OleDbDataReader

conn

=

New

OleDbConnection

conn.ConnectionString

=

"Provider=Microsoft.Jet.OleDb.4.0Data

Source=d:\\第一步\\user.mdb"

conn.Open()

str

=

"select

*

from

reg

where

userid='"

&

yonghu.Text

&

"'

"

'cmd

=

New

OleDbCommand(str,

conn)

'rd

=

cmd.ExecuteReader()

'If

rd.Read()

Then

'

End

If

da

=

New

OleDbDataAdapter(str,

conn)

da.Fill(ds)

'Dim

i

As

Integer

'i

=

ds.Tables(0).Rows.Count

'MsgBox(i)

If

ds.Tables(0).Rows.Count

=

0

Then

MsgBox("你还没有注册,请先注册会员")

Else

Dim

str2

As

String

str2

=

"select

*

from

reg

where

userid='"

&

yonghu.Text

&

"'

and

password='"

&

password.Text

&

"'"

da

=

New

OleDbDataAdapter(str2,

conn)

da.Fill(ds1)

If

ds1.Tables(0).Rows.Count

=

0

Then

MsgBox("密码错误")

Else

'window.top.document.location.href

=

"../huiyuah.aspx"

Session.Add("yonghuming",

yonghu.Text)

Response.Redirect("huiyuan.aspx")

End

If

End

If

conn.Close()


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12166900.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存