减乘除都会了,
只有加(Text3.Text=Text1.Text+Text2.Text)
,他总是把两个数拼起来。
求源码。
VBä¸çtextboxéçå
容é»è®¤æ¯stringç±»åï¼ï¼å¦æç¨+å·è¿æ¥ï¼å°±ä¼è®¤ä¸ºæ¯å符åæ°æ®åè¿æ¥è¿ç®ãå¦ææ³è¦ä½ä¸ºæ°åè¿è¡å æ³ï¼å°±å¿
须强å¶è½¬æ¢ç®ææ°å¼åï¼å¯ä»¥ç¨Valå½æ°æ¥å®ç°è½¬æ¢ã以å æ³ä¸ºä¾ï¼
Private Sub Command1_Click() 'å
Text3.Text = Val(Text1) + Val(Text2.Text)
Text1.Text = ""
Text2.Text = ""
End Sub
å ¶ä½å 个é¢ç®ï¼ä¹æ¯ä¸æ ·çéçã
Private Sub Command1_Click() 'å
Text3.Text = Val(Text1) + Val(Text2.Text)
Text1.Text = ""
Text2.Text = ""
End Sub
å ¶ä½å 个é¢ç®ï¼ä¹æ¯ä¸æ ·çéçã
温馨提示:答案为网友推荐,仅供参考
第1个回答 推荐于2017-09-25
Private Sub Command1_Click() '加
Text3.Text = Val(Text1) + Val(Text2.Text)
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command2_Click() '减
Text3.Text = Val(Text1) - Val(Text2.Text)
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command3_Click() '乘
Text3.Text = Val(Text1) * Val(Text2.Text)
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command4_Click() '除
Text3.Text = Val(Text1) / Val(Text2.Text)
Text1.Text = ""
Text2.Text = ""
End Sub
注:
textbox里的内容是是string类型,参与运算时应该强制转换算成数值型,用Val函数
你这里+号两端都是字符类型数据,在VB中是做连接运算。本回答被提问者和网友采纳
Text3.Text = Val(Text1) + Val(Text2.Text)
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command2_Click() '减
Text3.Text = Val(Text1) - Val(Text2.Text)
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command3_Click() '乘
Text3.Text = Val(Text1) * Val(Text2.Text)
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command4_Click() '除
Text3.Text = Val(Text1) / Val(Text2.Text)
Text1.Text = ""
Text2.Text = ""
End Sub
注:
textbox里的内容是是string类型,参与运算时应该强制转换算成数值型,用Val函数
你这里+号两端都是字符类型数据,在VB中是做连接运算。本回答被提问者和网友采纳
第2个回答 2012-06-21
Text3.Text = Val(Text1.Text) + Val(Text2.Text)