VB程序。单击第一个按钮,生成20个[1,50]之间的随机整数,显示于第一个文本框中

单击第一个按钮,生成20个[1,50]之间的随机整数,显示于第一个文本框中,单机第二个按钮,将这20个随机整数按从大到小的顺序排序,并将顺序结果显示于另一个文本框中。用数... 单击第一个按钮,生成20个[1,50]之间的随机整数,显示于第一个文本框中,单机第二个按钮,将这20个随机整数按从大到小的顺序排序,并将顺序结果显示于另一个文本框中。用数组程序写出。 展开
 我来答
匿名用户
推荐于2017-10-05
展开全部
2010年4月23日默认分类 2010-06-26 16:32:46 阅读18 评论0 字号:大中小 订阅
襄樊瑞源公司工资管理软件

编程:梁冬丰

Private Sub a2_Click()
Form6.Show

End Sub

Private Sub a3_Click()
CommonDialog1.CancelError = False

CommonDialog1.FileName = ""
CommonDialog1.Filter = "ALL FILES|*.*||(*.EXE)||*.EXE||(*.TXT)||*.TXT|"
CommonDialog1.FilterIndex = 1
CommonDialog1.DialogTitle = "SAVE FILE(*.MDB)"
CommonDialog1.Action = 2
If CommonDialog1.FileName = "" Then
MsgBox "请输入名称"
Else
FileCopy "d:\vb98\l.mdb", CommonDialog1.FileName
End If
End Sub

Private Sub a4_Click()

FIRSTPAGE = 1
LASTPAGE = 50
CommonDialog1.CancelError = True
CommonDialog1.Copies = 1
CommonDialog1.Min = FIRSTPAGE
CommonDialog1.Max = LASTPAGE
CommonDialog1.Flags = VBPDUSEDEVMODECOPIES Or VBPDSELECTION
CommonDialog1.Action = 5
Form8.Show

End Sub

Private Sub Command2_Click()
End Sub

Private Sub Command1_Click()

End Sub

Private Sub a5_Click()
End
End Sub

Private Sub a7_Click()
Form2.Show
End Sub

Private Sub A81_Click()
Form9.Show
End Sub

Private Sub A82_Click()
Form7.Show
End Sub

Private Sub Command1_Click()
If Option1 = True Then
CommonDialog1.FileName = ""
CommonDialog1.Flags = VBOFNFILEMUSTEXIT
CommonDialog1.Filter = "ALL FILES|*.*||(*.EXE)||*.EXE||(*.TXT)||*.TXT|"
CommonDialog1.FilterIndex = 3
CommonDialog1.DialogTitle = "打开文件"
CommonDialog1.Action = 1
If CommonDialog1.FileName = "" Then
MsgBox "请输入名称"
Else

FileCopy CommonDialog1.FileName, "d:\vb98\l.mdb"

End If
Unload Form6
End If
If Option2 = True Then
CommonDialog1.CancelError = False

CommonDialog1.FileName = ""
CommonDialog1.Filter = "ALL FILES|*.*||(*.EXE)||*.EXE||(*.TXT)||*.TXT|"
CommonDialog1.FilterIndex = 1
CommonDialog1.DialogTitle = "保存文件"

CommonDialog1.Action = 2
If CommonDialog1.FileName = "" Then
MsgBox "请输入名称"
Else
FileCopy "d:\vb98\l.mdb", CommonDialog1.FileName
Unload Form6
End If
End If
End Sub

Private Sub Command2_Click()
Unload Form6
End Sub
Private Sub Command5_Click()

Combo2.Visible = False
Combo1.Visible = False

Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = "SELECT*FROM D WHERE BZ='" & Combo1 & "'AND BM='" & Combo2 & "' "

Adodc1.Refresh
A = Adodc1.Recordset.RecordCount
Printer.Print Tab(84); Combo1; Tab(88); Combo2; Tab(92); "公司汇总打印预览表"
For I = 1 To A

Printer.Print Tab(13); "----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
Printer.Print Tab(13); "部门"; Tab(21); "班组"; Tab(29); "姓名"; Tab(37); "基本工资"; Tab(45); "扣款"; Tab(53); "中夜班"; Tab(61); "奖金"; Tab(69); "工龄"; Tab(77); "其他补资"; Tab(85); "车修"; Tab(93); "洗理"; Tab(101); "养老"; Tab(109); "医保"; Tab(117); "失业金"; Tab(125); "水电"; Tab(133); "借资"; Tab(141); "物业"; Tab(149); "有线"; Tab(157); "抵押"; Tab(165); "实际工资"
Printer.Print Tab(13); Adodc1.Recordset("BM"); Tab(21); Adodc1.Recordset("BZ"); Tab(29); Adodc1.Recordset("XM"); Tab(37); Adodc1.Recordset("GZ"); Tab(45); Adodc1.Recordset("KK"); Tab(53); Adodc1.Recordset("ZYB"); Tab(61); Adodc1.Recordset("JJ"); Tab(69); Adodc1.Recordset("GL"); Tab(77); Adodc1.Recordset("QT1"); Tab(85); Adodc1.Recordset("CX"); Tab(93); Adodc1.Recordset("XL"); Tab(101); Adodc1.Recordset("YL"); Tab(109); Adodc1.Recordset("YB"); Tab(117); Adodc1.Recordset("SY"); Tab(125); Adodc1.Recordset("SD"); Tab(133); Adodc1.Recordset("JZ"); Tab(141); Adodc1.Recordset("WY"); Tab(149); Adodc1.Recordset("YX"); Tab(157); Adodc1.Recordset("DY"); Tab(165); Adodc1.Recordset("SF")

Adodc1.Recordset.MoveNext

Next
Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = "SELECT*FROM D WHERE BZ='" & Combo1 & "'AND BM='" & Combo2 & "' "
Adodc1.Refresh

A = Adodc1.Recordset.RecordCount

For I = 1 To A
If I = 1 Then
T0 = Adodc1.Recordset("SF")
T1 = Adodc1.Recordset("GZ")
T2 = Adodc1.Recordset("KK")
T3 = Adodc1.Recordset("ZYB")
T4 = Adodc1.Recordset("JJ")
T5 = Adodc1.Recordset("GL")
T6 = Adodc1.Recordset("QT1")
T7 = Adodc1.Recordset("CX")
T8 = Adodc1.Recordset("XL")
T9 = Adodc1.Recordset("YL")
T10 = Adodc1.Recordset("YB")
T11 = Adodc1.Recordset("SY")
T12 = Adodc1.Recordset("SD")
T13 = Adodc1.Recordset("JZ")
T14 = Adodc1.Recordset("WY")
T15 = Adodc1.Recordset("YX")
T16 = Adodc1.Recordset("DY")

End If

Adodc1.Recordset.MoveNext

If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
Else
T0 = T0 + Adodc1.Recordset("SF")
T1 = T1 + Adodc1.Recordset("GZ")
T2 = T2 + Adodc1.Recordset("KK")
T3 = T3 + Adodc1.Recordset("ZYB")
T4 = T4 + Adodc1.Recordset("JJ")
T5 = T5 + Adodc1.Recordset("GL")
T6 = T6 + Adodc1.Recordset("QT1")
T7 = T7 + Adodc1.Recordset("CX")
T8 = T8 + Adodc1.Recordset("XL")
T9 = T9 + Adodc1.Recordset("YL")
T10 = T10 + Adodc1.Recordset("YB")
T11 = T11 + Adodc1.Recordset("SY")
T12 = T12 + Adodc1.Recordset("SD")
T13 = T13 + Adodc1.Recordset("JZ")
T14 = T14 + Adodc1.Recordset("WY")
T15 = T15 + Adodc1.Recordset("YX")
T16 = T16 + Adodc1.Recordset("DY")

End If

Next

Printer.Print Tab(10); "汇总"; Tab(18); "部门"; Tab(26); "班组"; Tab(34); "人数"; Tab(42); "基本工资"; Tab(50); "扣款"; Tab(58); "中夜班"; Tab(66); "奖金"; Tab(74); "工龄"; Tab(82); "其他补资"; Tab(90); "车修"; Tab(98); "洗理"; Tab(106); "养老"; Tab(114); "医保"; Tab(122); "失业金"; Tab(130); "水电"; Tab(138); "借资"; Tab(146); "物业"; Tab(154); "有线"; Tab(162); "抵押"; Tab(170); "实际工资"
Printer.Print Tab(10); "汇总"; Tab(18); Combo2; Tab(26); Combo1; Tab(34); A; Tab(42); T1; Tab(50); T2; Tab(58); T3; Tab(66); T4; Tab(74); T5; Tab(82); T6; Tab(90); T7; Tab(98); T8; Tab(106); T9; Tab(114); T10; Tab(122); T11; Tab(130); T12; Tab(138); T13; Tab(146); T14; Tab(154); T15; Tab(162); T16; Tab(170); T0

End Sub

Private Sub Form_Load()

Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = "SELECT*FROM D ORDER BY BZ"
Adodc1.Refresh
Dim T
A = Adodc1.Recordset.RecordCount
For I = 1 To A

If I = 1 Then
T = Adodc1.Recordset("BZ")
Combo1.AddItem T

End If

Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
End If

If T <> Adodc1.Recordset("BZ") Then
T = Adodc1.Recordset("BZ")
Combo1.AddItem T
Else
End If

Next
Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = "SELECT*FROM D ORDER BY BM"
Adodc1.Refresh
Dim T1
A = Adodc1.Recordset.RecordCount
For I = 1 To A

If I = 1 Then
T1 = Adodc1.Recordset("BM")
Combo2.AddItem T1

End If

Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
End If

If T1 <> Adodc1.Recordset("BM") Then
T1 = Adodc1.Recordset("BM")
Combo2.AddItem T1
Else
End If

Next
快乐_无敌
2010-12-02 · TA获得超过652个赞
知道小有建树答主
回答量:604
采纳率:0%
帮助的人:516万
展开全部
第一个按钮事件里写
Dim strRnd As String
Dim i As Integer
For i = 1 To 20 '生成20个随机数
strRnd = strRnd & Str(Int(50 * Rnd + 1))
Next
TextBox1 = Trim(strRnd) '将生成的20个随机数放到第一个文本框中

---------------------------------------------------
第二个按钮事件里写
Dim strRnd As String
Dim i As Integer
Dim j As Integer
Dim ArryStr() As String
Dim StrNew As String
ArryStr = Split(Trim(TextBox1), " ") '将TextBox1的值分割成数组
For i = 0 To UBound(ArryStr) '利用冒泡法对数组中的值进行排序
For j = 0 To UBound(ArryStr) - 1
If Int(ArryStr(j)) < Int(ArryStr(j + 1)) Then
StrNew = ArryStr(j + 1)
ArryStr(j + 1) = ArryStr(j)
ArryStr(j) = StrNew
End If
Next j
Next i

strRnd = ""
For i = 0 To UBound(ArryStr)
strRnd = strRnd & " " & ArryStr(i) '将数组中的值拼接成字符串
Next
TextBox2 = Trim(strRnd) '将排序后的数值显示到文本框里
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式