VB的Text1.text输入数字,点option1,text2.text逆序输出,点option2,text2.text显示求和
3个回答
展开全部
Private Sub Text1_Change()
If Option1.Value Then
Text2.Text = StrReverse(Text1.Text) '逆序
ElseIf Option2.Value Then
l = Len(Text1.Text)
For i = 1 To l
s = s + Val(Mid(Text1.Text, i, 1)) '求各数之和
Next i
Text2.Text = s
End If
End Sub
Private Sub Option1_Click()
Text1_Change
End Sub
Private Sub Option2_Click()
Text1_Change
End Sub
If Option1.Value Then
Text2.Text = StrReverse(Text1.Text) '逆序
ElseIf Option2.Value Then
l = Len(Text1.Text)
For i = 1 To l
s = s + Val(Mid(Text1.Text, i, 1)) '求各数之和
Next i
Text2.Text = s
End If
End Sub
Private Sub Option1_Click()
Text1_Change
End Sub
Private Sub Option2_Click()
Text1_Change
End Sub
展开全部
Private Sub Option1_Click()
Text2.Text = "逆序输出"
End Sub
Private Sub Option2_Click()
Text2.Text = "各数字和"
End Sub
Private Sub Option2_Click()
Text2.Text = "各数字积"
End Sub
Text2.Text = "逆序输出"
End Sub
Private Sub Option2_Click()
Text2.Text = "各数字和"
End Sub
Private Sub Option2_Click()
Text2.Text = "各数字积"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2008-11-19
展开全部
Dim str as string
Private Sub Form_load()
Text1 = ""
Text2 = ""
Option1.Caption = "逆序"
Option2.Caption = "求和"
Option3.Caption = "求积"
End Sub
Private Sub Option1_Click()
str = Text1.Text
Text2 = StrReverse(str) '逆序~StrReverse 用来返回一个字符串,其中一个指定子字符串的字符顺序是反向的
End Sub
Private Sub Option2_Click()
Text2.Text = Val(Text1.Text) + Val(Text2.Text) '求和~~Val 用来返回包含于字符串内的数字,字符串中是一个适当类型的数值
End Sub
Private Sub Option3_Click() '求积
str = Text1.Text
Text2 = StrReverse(str)
Text2.Text = Val(Text1.Text) * Val(Text2.Text)
End Sub
这够简单基本了吧。。你只要添加2个文本 3个单选 连名字我都给你设定好了
如果你要限制输入的只是数字 你也可以用下面的代码
Dim str
Private Sub Form_load()
Text1 = ""
Text2 = ""
Option1.Caption = "逆序"
Option2.Caption = "求和"
Option3.Caption = "求积"
End Sub
Private Sub Option1_Click()
str = Text1.Text
If IsNumeric(Text1.Text) = False Then
MsgBox "非数字请重新输入"
Else
Text2 = StrReverse(str)
End If
End Sub
Private Sub Option2_Click()
If IsNumeric(Text1.Text) = False Then
MsgBox "非数字请重新输入"
Else
Text2.Text = Val(Text1.Text) + Val(Text2.Text)
End If
End Sub
Private Sub Option3_Click()
If IsNumeric(Text1.Text) = False Then
MsgBox "非数字请重新输入"
Else
str = Text1.Text
Text2 = StrReverse(str)
Text2.Text = Val(Text1.Text) * Val(Text2.Text)
End If
End Sub
Private Sub Form_load()
Text1 = ""
Text2 = ""
Option1.Caption = "逆序"
Option2.Caption = "求和"
Option3.Caption = "求积"
End Sub
Private Sub Option1_Click()
str = Text1.Text
Text2 = StrReverse(str) '逆序~StrReverse 用来返回一个字符串,其中一个指定子字符串的字符顺序是反向的
End Sub
Private Sub Option2_Click()
Text2.Text = Val(Text1.Text) + Val(Text2.Text) '求和~~Val 用来返回包含于字符串内的数字,字符串中是一个适当类型的数值
End Sub
Private Sub Option3_Click() '求积
str = Text1.Text
Text2 = StrReverse(str)
Text2.Text = Val(Text1.Text) * Val(Text2.Text)
End Sub
这够简单基本了吧。。你只要添加2个文本 3个单选 连名字我都给你设定好了
如果你要限制输入的只是数字 你也可以用下面的代码
Dim str
Private Sub Form_load()
Text1 = ""
Text2 = ""
Option1.Caption = "逆序"
Option2.Caption = "求和"
Option3.Caption = "求积"
End Sub
Private Sub Option1_Click()
str = Text1.Text
If IsNumeric(Text1.Text) = False Then
MsgBox "非数字请重新输入"
Else
Text2 = StrReverse(str)
End If
End Sub
Private Sub Option2_Click()
If IsNumeric(Text1.Text) = False Then
MsgBox "非数字请重新输入"
Else
Text2.Text = Val(Text1.Text) + Val(Text2.Text)
End If
End Sub
Private Sub Option3_Click()
If IsNumeric(Text1.Text) = False Then
MsgBox "非数字请重新输入"
Else
str = Text1.Text
Text2 = StrReverse(str)
Text2.Text = Val(Text1.Text) * Val(Text2.Text)
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询