VB 代码哪里错了

来源:百度知道 编辑:UC知道 时间:2024/06/02 05:50:56
Dim a, b, c As Double

a = Text1.Text
b = Text2.Text
Select Case c
Case "+"
MsgBox = Val(a) + Val(b)
Case "-"
magbox = Val(a) - Val(b)
End Select
End Sub

Private Sub Command2_Click()
c = "+"
End Sub

Private Sub Command3_Click()
c = "-"
End Sub
Private Sub Command1_Click()

该dim什么一直搞不清 谁给讲讲

Dim a, b, c As Double 这句错了,你把c定义为double,他怎么能是“+”这样的运算符呢?
把double去掉
直接:
dim a,b,c

Dim a, b, c As Double
你这声明c是一个双精度类型的.
但你在Case 里,c成了string
当然有错了
改成
dim a as string ,b as string ,c as string
提醒下,在申明变量时,最好不要Dim a, b, c As Double的方式
这样a,b都是variant类型的.而不是你想申明的Double或者String类型.

dim c as string