我正在编写一个程序,让用户选择他们的星座和另一个人签名。一旦进入,我想使用这些标志来衡量它们的兼容性,其结果分为3类。我有程序,用户可以选择两个标志,程序可以吐出来告诉用户他们选择了什么(我不需要这个消息框,我只是这样做,检查我的代码正在运行)。我遇到问题的部分是"兼容性"功能和使用选择的情况,我不知道我是否需要声明新的变量,或者如果我公开它们它们是否会起作用。显然我的代码不起作用或者我不会寻求帮助。对于精选案例,我到目前为止只有一个用于Aries,但是需要为所有12个标志完成。
以下是新代码:
Public Class Form1
Public Sub btnBegin_Click(sender As Object, e As EventArgs) Handles btnBegin.Click
lblMySign.Visible = True
lblYourSign.Visible = True
cbMySign.Visible = True
cbYourSign.Visible = True
btnBegin.Visible = False
Dim MySign As String
Dim YourSign As String
MySign = cbMySign.Text
YourSign = cbYourSign.Text
Call Compatibility(Me.cbMySign.Text, Me.cbYourSign.Text)
End Sub
Public Sub cbMySign_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbMySign.SelectedIndexChanged
End Sub
Public Sub cbYourSign_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbYourSign.SelectedIndexChanged
'Dim MySign As String
'Dim YourSign As String
'MySign = cbMySign.Text
'YourSign = cbYourSign.Text
End Sub
Function Compatibility(cbMySign As String, cbYourSign As String) As String
Dim strCompat As String
Select Case cbMySign
Case "Aries"
Select Case cbYourSign
Case "Taurus", "Cancer", "Virgo", "Pisces"
strCompat = "NC"
Case "Gemini", "Libra", "Scorpio", "Capricorn", "Aquarius"
strCompat = "N"
Case "Aries", "Leo", "Sagittarius"
strCompat = "C"
End Select
End Select
If strCompat = "NC" Then
MsgBox("You're not compatible")
ElseIf strCompat = "N" Then
MsgBox("You're neutral")
Else
MsgBox("You're compatible")
End If
End Function
结束班
答案 0 :(得分:0)
下午3:10更新 对于迟到的回复感到抱歉,需要参加一系列的会议......
我尝试运行你的整个代码,复制粘贴并运行,它完美运行......
我试过了:
我的标志=白羊座 你的标志=处女座
结果:“你不兼容”
我的问题是,当你点击BtnBegin什么时候会再次出现?
lblMySign.Visible = True
lblYourSign.Visible = True
cbMySign.Visible = True
cbYourSign.Visible = True
btnBegin.Visible = False '--- here it is?
我认为你需要在点击cbMySign或cbYourSign
时重置这个-Strider(Yahoo!Answers)