【求助】該如何只要以一個label顯示出我所勾的選項字樣?(Visual Basic)



贊助商連結


赤色AMD軍團
2002-04-14, 10:39 PM
大大幫忙一下,在程式碼中,我想要在以一個label就可以顯示出我所打勾的選項,可是我的問題出在我必須增設很多的label才能對應我所選擇的東西....該怎麼辦?明天就要交作業了.....
圖例:
http://litweb.999host.net/vb.gif
我的VB程式檔案,幫我的人可以看看並且下載回去:
http://litweb.999host.net/homework.frm
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
我的程式碼:
Private Sub Command1_Click() ===>(確定的程式碼)

Label5.Caption = Text1.Text

If Option1.value = True Then
Label7.Caption = Option1.Caption
Else
If Option2.value = True Then
Label7.Caption = Option2.Caption
Else
Label7.Caption = ""
End If
End If

If Option3.value = True Then
Label9.Caption = Option3.Caption
Else
If Option4.value = True Then
Label9.Caption = Option4.Caption
Else
If Option5.value = True Then
Label9.Caption = Option5.Caption
Else
If Option6.value = True Then
Label9.Caption = Option6.Caption
Else
Label9.Caption = ""
End If
End If
End If
End If

If Check1.value = 1 Then
Label11.Caption = Check1.Caption
Else
Label11.Caption = ""
End If
If Check2.value = 1 Then
Label12.Caption = Check2.Caption
Else
Label12.Caption = ""
End If
If Check3.value = 1 Then
Label13.Caption = Check3.Caption
Else
Label13.Caption = ""
End If

End Sub

Private Sub Command2_Click() ===>(清除的程式碼)
Text1.Text = ""
Option1.value = False
Option2.value = False
Option3.value = False
Option4.value = False
Option5.value = False
Option6.value = False
Check1.value = 0
Check2.value = 0
Check3.value = 0
Label5.Caption = ""
Label7.Caption = ""
Label9.Caption = ""
Label11.Caption = ""
Label12.Caption = ""
Label13.Caption = ""
End Sub

Private Sub Command3_Click() ===>(結束的程式碼)
End
End Sub
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
:confused:

贊助商連結


xbug
2002-04-15, 09:46 AM
直接將字串相加不就好了?!
ex:
Label11.Caption = "我的興趣是:"
If Check1.value = 1 Then
Label11.Caption = Label11.Caption + Check1.Caption
End If
If Check2.value = 1 Then
Label12.Caption = Label11.Caption + Check2.Caption
End If
If Check3.value = 1 Then
Label13.Caption = Label11.Caption + Check3.Caption
End If

沒學過 vb, 不過應該沒錯吧.... :<

Janova
2002-04-15, 11:51 AM
元件相加哦....使用"&"

例如:
XX = Label1.caption & Label2.caption