完整代码如下:
Option ExplicitPrivate D As String
Private W As String
Private Sub Command1_Click()
MsgBox D & W
End Sub
Private Sub Form_Load()
Option1Caption = "星期一"
Option2Caption = "星期二"
Option3Caption = "星期三"
Option4Caption = "星期四"
Option5Caption = "星期五"
Option6Caption = "星期六"
Option7Caption = "星期天"
Option1Value = True
D = "星期一"
Option8Caption = "上课"
Option9Caption = "休息"
Option8Value = True
W = "上课"
End Sub
Private Sub Option1_Click()
D = Option1Caption
End Sub
Private Sub Option2_Click()
D = Option2Caption
End Sub
Private Sub Option3_Click()
D = Option3Caption
End Sub
Private Sub Option4_Click()
D = Option4Caption
End Sub
Private Sub Option5_Click()
D = Option5Caption
End Sub
Private Sub Option6_Click()
D = Option6Caption
End Sub
Private Sub Option7_Click()
D = Option7Caption
End Sub
Private Sub Option8_Click()
W = Option8Caption
End Sub
Private Sub Option9_Click()
W = Option9Caption
End Sub
用VB实现上述功能的函数是:
Function fun(m, n) As Integer
Sum = 0
For i = 1 To 100
If i Mod m = 0 Or i Mod n = 0 Then
Sum = Sum + i
End If
Next i
fun = Sum
End Function
Private Sub Command1_Click()
m = CInt(InputBox("m="))
n = CInt(InputBox("n="))
Print "100以内能被"; m; "或"; n; "整除的数的总和="; fun(m, n)
End Sub
' 下面的代码就可以解决你的问题
dim sta,i%,st$,a$,b$,c$
st = “ax^2+bx+c=0” ' 这里你可以改成从文本框获取方程
sta = split(st,"+")
for i = 0 to ubound(sta)
if instr(sta(i) , "x^2")>0 then
a = trim( left(sta(i),instr(sta(i) , "x^2") -1))
elseif instr(sta(i) , "x")>0 then
b = trim( left(sta(i),instr(sta(i) , "x") -1))
elseif instr(sta(i) , "=")>0 then
c = trim( left(sta(i),instr(sta(i) , "=") -1))
end if
next i
Private Sub Command1_Click()
Dim a
Static zs, fs
a = InputBox("请输入数据,0结束")
Print a
If a <> 0 Then
If Val(a) > 0 Then zs = zs + 1 Else fs = fs + 1
Else
Print "正数个数="; zs, "负数个数="; fs
End If
End Sub
以上就是关于用vb做一个程序全部的内容,包括:用vb做一个程序、用vb编写程序、用VB编写程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)