请高手帮忙做一个VB小程序,有做好的界面,帮忙把代码填进去就OK.
1个回答
展开全部
'------------------------定义变量
Dim IsA, IsB, IsC, IsD As Boolean '定义谁是小偷
Dim HA, HB, HC, HD As Boolean '定义是否说真话
Dim PdTrue As Boolean '判断是否为真
Private Sub Command1_Click()
'------------------------初始化
IsA = False
IsB = False
IsC = False
IsD = False
HA = True
HB = True
HC = True
HD = True
PdTrue = True
'------------------------获取隐乎前用户输入谁是小偷
Text1.Text = UCase(Text1.Text) '使在text1输入的字母变成大写.
If Text1 <> "A" And Text1 <> "B" And Text1 <> "C" And Text1 <> "D" Then
MsgBox "请在text1中正确输入小偷..(可选A、B、C、D)", 48, "提示!"
Exit Sub
End If
Select Case Text1.Text
Case "A"
IsA = True
Case "B"
IsB = True
Case "C"
IsC = True
Case "D"
IsD = True
End Select
'------------------------------'根据只有一个小偷,引出判断。
Select Case PdTrue
Case IsA '如果A是小偷,则其他的人不是小偷
IsB = False
IsC = False
IsD = False
Case IsB '如果是B小偷
IsA = False
IsC = False
IsD = False
Case IsC '如果是C小偷灶清
IsA = False
IsB = False
IsD = False
Case IsD '如果是D小偷
IsA = False
IsB = False
IsC = False
End Select
'---------------------------------根据语言矛盾,判断真假!顷正
HA = Not (IsA)
HB = IsC
HC = IsD
HD = Not (IsD)
'---------------------------------
If HA = True Then
Text2 = "√"
Else
Text2 = "×"
End If
If HB = True Then
Text3 = "√"
Else
Text3 = "×"
End If
If HC = True Then
Text4 = "√"
Else
Text4 = "×"
End If
If HD = True Then
Text5 = "√"
Else
Text5 = "×"
End If
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Dim IsA, IsB, IsC, IsD As Boolean '定义谁是小偷
Dim HA, HB, HC, HD As Boolean '定义是否说真话
Dim PdTrue As Boolean '判断是否为真
Private Sub Command1_Click()
'------------------------初始化
IsA = False
IsB = False
IsC = False
IsD = False
HA = True
HB = True
HC = True
HD = True
PdTrue = True
'------------------------获取隐乎前用户输入谁是小偷
Text1.Text = UCase(Text1.Text) '使在text1输入的字母变成大写.
If Text1 <> "A" And Text1 <> "B" And Text1 <> "C" And Text1 <> "D" Then
MsgBox "请在text1中正确输入小偷..(可选A、B、C、D)", 48, "提示!"
Exit Sub
End If
Select Case Text1.Text
Case "A"
IsA = True
Case "B"
IsB = True
Case "C"
IsC = True
Case "D"
IsD = True
End Select
'------------------------------'根据只有一个小偷,引出判断。
Select Case PdTrue
Case IsA '如果A是小偷,则其他的人不是小偷
IsB = False
IsC = False
IsD = False
Case IsB '如果是B小偷
IsA = False
IsC = False
IsD = False
Case IsC '如果是C小偷灶清
IsA = False
IsB = False
IsD = False
Case IsD '如果是D小偷
IsA = False
IsB = False
IsC = False
End Select
'---------------------------------根据语言矛盾,判断真假!顷正
HA = Not (IsA)
HB = IsC
HC = IsD
HD = Not (IsD)
'---------------------------------
If HA = True Then
Text2 = "√"
Else
Text2 = "×"
End If
If HB = True Then
Text3 = "√"
Else
Text3 = "×"
End If
If HC = True Then
Text4 = "√"
Else
Text4 = "×"
End If
If HD = True Then
Text5 = "√"
Else
Text5 = "×"
End If
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询