combo的style选2,然后输入以下代码:
Dim Money As Integer
Private Sub Combo1_Click()
C
End Sub
Private Sub Combo2_Click()
C
End Sub
Private Sub Form_Load()
With Combo1
AddItem "A"
AddItem "B"
AddItem "C"
AddItem "D"
Text = "A"
End With
With Combo2
AddItem "海运"
AddItem "陆运"
Text = "海运"
End With
C
End Sub
Private Sub C()
Select Case Combo1Text
Case "A"
Money = 1
Case "B"
Money = 2
Case "C"
Money = 3
Case "D"
Money = 5
End Select
If Combo2Text = "海运" Then
Money = Money + 10
Else
Money = Money + 100
End If
Text1Text = Money & "块钱"
End Sub
Label2Caption = Abs(Val(Text1Text)) ' val(text1text)是把text1里的文字转换成数字 ,ABS()是一个取绝对值得函数
下面是笨办法,但是可以搞懂是怎么回事
if val(text1text)>0 then
label2caption=text1text
else
label2caption=0-val(text1text) ' val(text1text)是把text1里的文字转换成数字
end if
楼主您好!
代码如下:
Option ExplicitPrivate Sub Command1_Click()
Dim n(7) As Double
Dim k(3) As Double
k(3) = 1
Dim j As Integer
For j = 1 To 7
n(j) = Val(Controls("Text" & CStr(j))Text)
Next j
For j = 1 To 7
k(1) = k(1) + n(j)
k(2) = k(2) - n(j)
k(3) = k(3) n(j)
Next j
MeText8Text = "7个数的和为:" & k(1) & vbCrLf & _
"7个数的差为:" & k(2) & vbCrLf & _
"7个数的乘积为:" & k(3)
End Sub
Private Sub Command2_Click()
Dim i As Integer
For i = 1 To 8
Controls("Text" & CStr(i))Text = ""
Next i
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 8
Controls("Text" & CStr(i))Text = ""
Next i
End Sub
Private Sub Combo1_Click()
File1Pattern = Combo1Text
End Sub
Private Sub Dir1_Change()
File1Path = Dir1Path
End Sub
Private Sub Drive1_Change()
Dir1Path = Drive1Drive
End Sub
Private Sub File1_Click()
MsgBox File1FileName
End Sub
Private Sub Form_Load()
Combo1AddItem "txt"
Combo1AddItem "dat"
Combo1AddItem "jpg;wmf;gif"
Combo1AddItem ""
Combo1Text = "txt"
File1Pattern = "txt"
End Sub
不一定符合您的要求,但绝对有用
给你个计算器的代码
一个单选按钮组,里面有4个单选按钮
3个文本框
1个命令按钮
代码如下
Private Sub Command1_Click()
Dim a, b, r As Double
Dim x As Integer
a = Val(Text1Text)
b = Val(Text2Text)
r = 0
If (Option1(0)Value) Then
r = a + b
ElseIf (Option1(1)Value) Then
r = a - b
ElseIf (Option1(2)Value) Then
r = a b
ElseIf (Option1(3)Value) Then
r = a / b
End If
Text3 = r
End Sub
Private Sub Form_Load()
Option1(0)Value = True
End Sub
Private Sub form_click()
MeShow
m = 10
n = 1
Print Int(Rnd (m - n - 1) + n + 1)
End Sub
第二题
Private Sub Form_Load()
Timer1Enabled = True
Timer1Interval = 1000
End Sub
Private Sub Timer1_Timer()
Cls
Print Format(Now, "long date") & " " & Time
End Sub
以上就是关于VB编写一个自动运算的小程序全部的内容,包括:VB编写一个自动运算的小程序、关于用VB6.0写个小程序计算绝对值~~~跪求高手指点..、用vb编写一个小程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)