vb代码怎么写 10
Private Sub Command1_Click()
If Option1.Value = True Then
Text2 = Sin(Val(Text1))
End If
If Option2.Value = True Then
Text2 = Exp(Val(Text1))
End If
If Option3.Value = True Then
Text2 = Sqr(Val(Text1))
End If
If Check1.Value = 1 Then
Text2.FontBold = True
End If
If Check2.Value = 1 Then
Text2.FontItalic = True
End If
End Sub
Private Sub Form_Load()
Label1.Caption = "参数"
Label2.Caption = "结果"
Command1.Caption = "计算"
Frame1.Caption = ""
Frame2.Caption = ""
Option1.Caption = "sin"
Option2.Caption = "exp"
Option3.Caption = "sqr"
Check1.Caption = "粗体"
Check2.Caption = "斜体"
Text1 = 4
Text2 = ""
Text2.BackColor = &H80000006
Text2.BorderStyle = 0
Text2.FontSize = 20
Option3.Value = True
End Sub
1.text1里面要求输入数字,然后增加一个按钮。
2.对text1设定只能输入数字以及最多输入三个数字
3.输入数字完成后点击按钮,首先用截取函数分别截取text1中各个数字,然后用if…then 判断语句来比较数字大小和类型,对于符合要求的即显示。。。
例如截取后三个数字分别是X Y Z ,if y=x,z=y,then '即msgbox"豹子"
if y=x+1,z=y+1,then msgbox"顺子"
以此类推。。。
因为我对你以上所讲的理解就是这样。所以,代码大概也就是这样了。
知道啊,怎么具体代码
具体代码怎么写
a = Val(Mid(Text1.Text, 1, 1))
b = Val(Mid(Text1.Text, 2, 1))
c = Val(Mid(Text1.Text, 3, 1))
For i = 1 To 3 '将数字重新按从小到大排列
If a > b Then
d = a
a = b
b = d
End If
If b > c Then
d = b
b = c
c = d
End If
Next i
If a = b And b = c Then
MsgBox "baozi"
Exit Sub
End If
If (a + 1) = b Then
If (b + 1) = c Then
MsgBox " shuzi"
Else
MsgBox "Banshu"
End If
Exit Sub
End If
If (b + 1) = c Then
MsgBox "Banshun"
Else
MsgBox "Sanma"
End If
然后判断:
if inputs="000" then
if inputs="888" then ‘这两个简单。
if instr(1,inputs,"0")>0 and instr(1,inputs,"1")>0 and instr(1,inputs,"2")>0 then '出现 "012",其他的自己写了。
以下的是判断有一对的,麻烦一点,用到下面的函数。
if StringCount(inputs,"0")=2 and StringCount(inputs,"2")=1 then '出现"002",其他的自己写。
Function StringCount(SourceString As String, SearchString As String)
Dim CountN As Integer, BeginN As Integer
CountN = 0
BeginN = 0
Do
BeginN = InStr(BeginN + 1, SourceString, SearchString)
If BeginN = 0 Then Exit Do
CountN = CountN + 1
DoEvents
Loop
StringCount = CountNEnd Function
广告 您可能关注的内容 |