vb 3个text,一个按钮,怎么设定a=1,b=2,然后在text1,text2中输入a和b,点击按钮实现a+b并text3出现3
定义a=1,b=2,c=3.......text1输入字母a,text2输入字母b,实现text3输出3,text1输入字母a,text2输入字母c,text3输出4.。...
定义a=1,b=2,c=3....... text1输入字母a,text2输入字母b,实现text3输出3,text1输入字母a,text2输入字母c,text3输出4.。。是这种情况
展开
2个回答
展开全部
Option Explicit
Private Const a As Long = 1
Private Const b As Long = 2
Private Const c As Long = 3
Private Function GetValue(ByVal Value As String) As Long
Select Case LCase(Trim(Value))
Case "a": GetValue = a
Case "b": GetValue = b
Case "c": GetValue = c
Case Else: GetValue = 0
End Select
End Function
Private Sub Command1_Click()
Text3.Text = GetValue(Text1.Text) + GetValue(Text2.Text)
End Sub
Private Const a As Long = 1
Private Const b As Long = 2
Private Const c As Long = 3
Private Function GetValue(ByVal Value As String) As Long
Select Case LCase(Trim(Value))
Case "a": GetValue = a
Case "b": GetValue = b
Case "c": GetValue = c
Case Else: GetValue = 0
End Select
End Function
Private Sub Command1_Click()
Text3.Text = GetValue(Text1.Text) + GetValue(Text2.Text)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询