用VB6.0设计简单程序
建议使用一些实例练习一下,熟悉一下各种空间,和控件的属性,变成就是对控件和控件属性的应用。最小下载一些小型实例来看看,改改,祝你飞速进步谢谢。
'给个短的给你,用的控件数组'添加按钮cmdNum(10),其index为0到9,表示10个数字'添加按钮cmdOper(4),其index为1到4,表示运算符'添加按钮cmdOk,为等于号'添加按钮cmdClear,为清除按钮'然后添加如下代码:Dim flag As IntegerDim isClickNumLast As BooleanDim s1 As String '前一步的值Dim s2 As String '当前框中的值Private Sub Form_Load() isClickNumLast = True flag = 1End Sub'点数字的操作Private Sub cmdNum_Click(Index As Integer) Text1.Text = IIf(isClickNumLast, Text1.Text, "") & CStr(Index) isClickNumLast = TrueEnd Sub'点运算符的操作Private Sub cmdOper_Click(Index As Integer) If isClickNumLast Then Call computeResult Text1.Text = s1 End If flag = Index isClickNumLast = FalseEnd Sub'得出结果Private Sub cmdOK_Click() Call computeResult Text1.Text = s1 isClickNumLast = FalseEnd Sub'清屏Private Sub cmdClear_Click() '清屏 Text1.Text = "" isClickNumLast = True flag = 1End Sub'计算结果Private Sub computeResult() s2 = Text1.Text Select Case flag 'flag为运算符,分别为+-*/ Case 1 s1 = CStr(Val(s1) + Val(s2)) Case 2 s1 = CStr(Val(s1) - Val(s2)) Case 3 s1 = CStr(Val(s1) * Val(s2)) Case 4 s1 = CStr(Val(s1) / Val(s2)) End SelectEnd Sub'界面预览:'
'源码下载:'http://www.ruiyuan-power.com/sfw/calc.rar
'利用随机函数产生60个100~200之间的随机整数,将其中的偶数按由小到大的顺序排列并输出,将奇数按由大到小的顺序排列并输出。
'1.将随机产生的60个整数按每行10个数输出到窗体或文本框中。
'2.将排好序的偶数和奇数分别输出到两个文本框中。
Dim RndArray(6, 10) As Integer
Dim OddArray() As Integer
Dim EvenArray() As Integer
Dim i, j As Integer
Dim m, n As Integer
Private Sub Cmd_Exit_Click()
'销毁数组
Unload Me
End Sub
Private Sub Cmd_Start_Click()
'除数化
Me.Txt(0).Text = ""
Me.Txt(1).Text = ""
Me.Txt(2).Text = ""
ReDim OddArray(60)
ReDim EvenArray(60)
For i = 0 To 5 Step 1
For j = 0 To 9 Step 1
RndArray(i, j) = RndNuN(100, 200)
Next j
Next i
For i = 0 To 5 Step 1
For j = 0 To 8 Step 1
Me.Txt(0).Text = Me.Txt(0).Text + Trim(Str(RndArray(i, j))) + ","
Next j
Me.Txt(0).Text = Me.Txt(0).Text + Trim(Str(RndArray(i, j))) + vbCrLf
Next i
m = 0
n = 0
For i = 0 To 5 Step 1
For j = 0 To 9 Step 1
If RndArray(i, j) Mod 2 Then
OddArray(m) = RndArray(i, j)
m = m + 1
Else
EvenArray(n) = RndArray(i, j)
n = n + 1
End If
Next j
Next i
ReDim Preserve OddArray(m)
ReDim Preserve EvenArray(n)
DwComp OddArray(), m
UpComp EvenArray(), n
m = m - 1
n = n - 1
For i = 0 To m Step 1
Me.Txt(1) = Me.Txt(1) + Trim(Str(OddArray(i))) + ","
Next i
For i = 0 To n Step 1
Me.Txt(2) = Me.Txt(2) + Trim(Str(EvenArray(i))) + ","
Next i
End Sub
Public Function RndNuN(ByVal Min As Integer, ByVal Max As Integer)
RndNuN = Min + (Max - Min) * Rnd
End Function
Public Function UpComp(ByRef parray() As Integer, ByVal num As Integer)
Dim temp As Integer
num = num - 2
For i = 0 To num Step 1
For j = 0 To num Step 1
If parray(j) > parray(j + 1) Then
temp = parray(j)
parray(j) = parray(j + 1)
parray(j + 1) = temp
End If
Next j
Next i
End Function
Public Function DwComp(ByRef parray() As Integer, ByVal num As Integer)
Dim temp As Integer
num = num - 2
For i = 0 To num Step 1
For j = 0 To num Step 1
If parray(j) < parray(j + 1) Then
temp = parray(j)
parray(j) = parray(j + 1)
parray(j + 1) = temp
End If
Next j
Next i
End Function
'利用随机函数产生100个10~99之间的随机整数,找出其中的素数,并将这些素数求和。
'1. 将随机产生的100个整数存入数组,按每行10个数输出到窗体或文本框中。
'2. 用Sub子过程或Function函数过程判断随机整数是否为素数。
'3. 将素数按每行10个数在窗体或文本框中输出。
'4. 将素数的个数以及求和结果出到窗体或文本框中。
Dim RndArray(10, 10) As Integer
Dim PrimArray() As Integer
Dim i, j As Integer
Dim m, n As Integer
Dim num As Integer
Dim sum As Integer
Private Sub Cmd_Click(Index As Integer)
If Index Then
Unload Me
Else
'初始化
Me.Txt(0).Text = ""
Me.Txt(1).Text = ""
Me.Txt(2).Text = ""
Me.Txt(3).Text = ""
For i = 0 To 9 Step 1
For j = 0 To 9 Step 1
RndArray(i, j) = RndNuN(10, 99)
Next j
Next i
For i = 0 To 9 Step 1
For j = 0 To 8 Step 1
Me.Txt(0).Text = Me.Txt(0).Text + Trim(Str(RndArray(i, j))) + ","
Next j
Me.Txt(0).Text = Me.Txt(0).Text + Trim(Str(RndArray(i, j))) + vbCrLf
Next i
m = 0
n = 0
num = 0
sum = 0
ReDim PrimArray(10, 10)
For i = 0 To 9 Step 1
For j = 0 To 9 Step 1
If IsPrime(RndArray(i, j)) Then
PrimArray(m, n) = RndArray(i, j)
Me.Txt(1).Text = Me.Txt(1).Text + Trim(Str(PrimArray(m, n))) + ","
sum = sum + PrimArray(m, n)
n = n + 1
If n > 9 Then
m = m + 1
n = 0
End If
num = num + 1
End If
Next j
Next i
Me.Txt(2).Text = Trim(Str(num))
Me.Txt(3).Text = Trim(Str(sum))
End If
End Sub
Public Function RndNuN(ByVal Min As Integer, ByVal Max As Integer)
RndNuN = Min + (Max - Min) * Rnd
End Function
Public Function IsPrime(ByVal n As Integer) As Boolean
Dim a, b As Integer
IsPrime = False
If n Mod 2 Then
b = Sqr(n)
For a = 3 To b Step 2
If n Mod a = 0 Then
Exit Function
End If
Next a
IsPrime = True
End If
End Function
这是代码粘贴进去就可以用 只需要一个command按钮
如果还有问题联系我 QQ:294121192
Dim a(), b(1 To 60), c(1 To 60) As Integer
Private Sub Command1_Click()
num1 = 0: num2 = 0
n = 6
m = 10
ReDim a(n, m)
For i = 1 To n
For j = 1 To m
a(i, j) = Int(Rnd * 101 + 100)
Print a(i, j); " ";
If j Mod m = 0 Then Print
Next
Next
For i = 1 To n
For j = 1 To m
If a(i, j) Mod 2 = 0 Then
num1 = num1 + 1
b(num1) = a(i, j)
Else
num2 = num2 + 1
c(num2) = a(i, j)
End If
Next
Next
Print "偶数由小到大排列:"
For i = 1 To num1 - 1
For j = i + 1 To num1
If b(i) > b(j) Then
temp = b(i)
b(i) = b(j)
b(j) = temp
End If
Next
Next
For i = 1 To num1
Print b(i); "<=";
If i Mod 10 = 0 Then Print
Next
Print b(num1)
Print "奇数由大到小排列:"
For i = 1 To num2 - 1
For j = i + 1 To num2
If c(i) < c(j) Then
temp = c(i)
c(i) = c(j)
c(j) = temp
End If
Next
Print c(i); ">=";
If i Mod 10 = 0 Then Print
Next
Print c(num2)
End Sub
在线跪求VB6.0做一个简单题目
Private Function Num2Str(wsfNum As Double) As String Dim s() As String Dim ss As String Dim n As Integer Dim Temp1 As String Dim Temp2 As String Dim temp3 As String Temp1 = "壹贰叁肆伍陆柒捌玖"Temp2 = "亿仟佰拾万仟佰拾元"temp3 = "角分"If wsfNum >= 1000000000 Then...
用vb6.0中实现简单的功能,高手请帮忙……100分
TipsData = Split(StrConv(InputB(LOF(FreeNum), #FreeNum), vbUnicode), Chr(13) + Chr(10))Close #FreeNum GetTips = True End Function Private Sub Text1_Change()Dim FreeNum As Integer, Str As String FreeNum = FreeFile Dim TempA() As String, TempB() As String, AppPlace...
VB6.0中编辑一个简单的计算器的代码
在加法的按钮框输入 text3.text=val(text1.text)+val(text2.text)在清除的按框输入 text3.text="" text2.text="" text1.text+=""
用VB 6.0制作下列程序
Me.Cls Call gcd(10)End Sub Function gcd(ByVal sl As Long)Dim j As Long, n As Long, nn(10) As Long, k As Long, mm As Long mm = 200 For j = 1 To sl Randomize nn(j) = 20 + Rnd() * 180 If mm >= nn(j) Then mm = nn(j)End If Print j & vbTab & nn...
用简单的vb6.0程序设计一“登录”对话框,缺省的用户名和密码均为“ADM...
我觉得应该是这样写:在窗口中添加两个text和一个command 首先是将text2和command1的enabled设置为false,然后:private sub text1_change()text2.enabled=true'当text1发生变化时,激活text2 end sub 然后是:...text2_change()command1.enabled=true'当text2发生变化时,激活command1 end sub privat...
vb6.0 怎么做啊
如图所示,望采纳。。。
用VB6.0设计一个小学数学出题系统
private sub_command1.click()command1.caption="OK"text3.text=""form1.caption="小学数学出题系统"dim num1 as integer dim num2 as integer dim flag as single dim sign as string dim result as single flag=rnd()select case flag case 0 to 0.25 sign ="+"case 0.25 to 0.5 si...
用VB6.0写出
代码:Private Sub Command1_Click() Me.Caption = "Cycle number" Dim a() As Integer, b() As Integer, n As Integer n = InputBox("Pleace input number of people:", "Input box", 17) m = n ReDim a(1 To n) For i = 1 To n a(i) = i - 1 Print...
vb6.0怎么制作一个抽奖小程序? vb6.0抽奖器的制作方法
这说明已经达到所预期的功能了。15、执行文件-生成抽奖.exe,这样经过编译就生成了可执行文件,这样就可以跨平台操作了,不再依赖原始程序。接 着执行文件-保存命令, 把所有的源文件进行保存即可,以方便以后修改使用。以上就是vb6.0中设计抽奖器的教程,希望大家喜欢,请继续关注我们。
VB6.0初学者的10个编程小技巧
1、如果一行程序太长,能不能换行?VB的程序代码是允许换行书写的,只要在每次换行的最后一个字符加上换行字符“_”就可以了。例如:Sub PicMove()Frm.Picture2.Left = Frm.Picture1.Left + _ ’加上换行符 Frm.Picture1.Width End Sub 2、 如何在设计的时候清空存在的图片?用鼠标点中该图片,...
彘狠盐酸: '给个短的给你,用的控件数组 '添加按钮cmdNum(10),其index为0到9,表示10个数字 '添加按钮cmdOper(4),其index为1到4,表示运算符 '添加按钮cmdOk,为等于号 '添加按钮cmdClear,为清除按钮 '然后添加如下代码: Dim flag As Integer ...
贡觉县17726916580: 用VB编个简单的程序. - ?
彘狠盐酸: Private Sub Command1_Click() Dim a(3) As Double For i = 0 To 2 a(i) = InputBox("请输入第" & i & "个数字:") Next iFor i = 2 To 0 Step -1For j = 0 To i - 1If a(j) < a(j + 1) Then temp = a(j): a(j) = a(j + 1): a(j + 1) = tempNext j Next iFor i = 0 To 2 Print a(i) Next i End Sub
贡觉县17726916580: 用vb6.0中实现简单的功能,高手请帮忙……100分?
彘狠盐酸: 谢谢您的支持. 在您的那个基础上又修改了一下. Option Explicit Dim IsInput As Boolean Private Sub Command1_Click() Dim FreeNum As Integer Dim TempA() As String, TempB() As String, AppPlace As String, KeyWord As String Dim L As ...
贡觉县17726916580: VB 6.0 教我编一个小程序 - ?
彘狠盐酸: For a = 1 To 9 For b = 1 To a Print a; "*"; b; "="; a * b; Next b Print Next a
贡觉县17726916580: 用vb6.0做一个小游戏 - ?
彘狠盐酸: 你说的贪吃蛇、推箱子都不简单,涉及到很多方面的设计,要花不少时间的.这里估计很少有人能帮得上你.祝你好运.帮你做了一个简单的猜数游戏,代码如下: '只需给窗体添加一个Command1的控件,单击它即可执行,允许多次执行 ...
贡觉县17726916580: 用vb6.0叙述建立一个完整的应用程序的过程 - ?
彘狠盐酸: ?一个简单的应用程序吗?新建一个不就得了贝.如果是信息系统的话.就要考虑加一些模块.如类模块.数据模块等.
贡觉县17726916580: 请问你们谁有一个比较有意思的用VB6.0编辑的程序?我想参考一下,麻烦发我邮箱! - ?
彘狠盐酸: 编写一个简单动画程序,实现以下功能1) 红色小球自动从图片框的左侧移动到右侧,反复运行.2) 拖动滚动条滑块可以调节小球的运行速度.3)...
贡觉县17726916580: 怎么用vb做一个简单的程序?
彘狠盐酸: 加入标签Label1,Caption设置为“你好,请输入你的姓名” 加入文本框Text1,用来输入姓名的 加入标签Label2,按照你的要求设置字体属性,autosize属性设成true 分别加入确定,继续,结束按钮 以下是代码: Private Sub Form_Load() Me.结...
贡觉县17726916580: VB6.0程序设计的步骤及例子,谢谢啦 - ?
彘狠盐酸: 例如,下面的脚本就是要返回安装在本地计算机上的磁盘集合然后返回它们的盘符:1 Set objFSO = CreateObject("Scripting.FileSystemObject")2 Set colDrives = objFSO.Drives3 For Each objDrive in colDrives4 Wscript.Echo "Drive letter: " & objDrive.DriveLetter5 Next
贡觉县17726916580: vb 编写一个简单程序?
彘狠盐酸: 主要是求满足 N = M 时的 X 吧.为什么写得这么复杂呢...汗;; A*B+A*B*0.003+A*B*0.001+1 = =(A+X)*B-(A+X)*B*0.003-(A+X)*B*0.001-1 A*B*0.006+A*B*0.002+2 = X*B-X*B*0.003-X*B*0.001 A*B*0.008+2 = X*B*0.996 X = (A*B*0.008+2)/(B*0.996) '-- If X >= 0.001 Then X = Round(X, 3) Else '把X初始化 End If '显出 X 完毕