uc头条怎么赚钱:VB编程运算符号问题

来源:百度文库 编辑:高校问答 时间:2024/05/05 14:23:05
怎样用VB计算并打印出来下面问题呢?(运算符号不可以直接写出来)
1+2+3=
1+2-3=
1+2*3=
1+2/3=
1-2+3=
1-2-3=
1-2*3=
1-2/3=
1*2+3=
1*2-3=
1*2*3=
1*2/3=
1/2+3=
1/2-3=
1/2*3=
1/2/3=

Public Function StrCount(StrA As String, StrB As String, StrAB As String) As Double
Select Case StrAB
Case "+"
StrCount = Val(StrB) + Val(StrA)
Case "-"
StrCount = Val(StrB) - Val(StrA)
Case "*"
StrCount = Val(StrB) * Val(StrA)
Case "/"
If Val(StrA) = 0 Then
MsgBox "运算过程中出现0值除数,程序被迫终止。", vbCritical, "出错提示"
End
End If
StrCount = Val(StrB) / Val(StrA)
Case "^"
If Val(StrB) = 0 And Val(StrA) < 0 Then
MsgBox "运算过程中出现0值除数,程序被迫终止。", vbCritical, "出错提示"
End
End If
StrCount = Val(StrB) ^ Val(StrA)
End Select
End Function

这是涉及计算的一个函数

Private Sub Form_Click()
m = Array("+", "-", "*", "/")
For i = 0 To 3
For j = 0 To 3
Print "1" & m(i) & "2" & m(j) & "3="
Next j
Next i
End Sub