2013-06-21 56 views
0

如果複選框未勾選,爲什麼文本框內的文本不會更改?如果沒有選中,那麼文本框的文本應該有「-g no」,但是當Command1被點擊時它不會改變。任何解決方案可能有些非常簡單的事情,但我只是沒有成功。 :\VB6爲什麼這不會改變? [複選框和文本框]

我的代碼:

Private Sub Command1_Click() 
    If Check1.Enabled = True Then 
     If TextPass.Text = "" Then 
      Text1.Text = "-o " & TextPool.Text & ":" & TextPort.Text & " -u " & TextUser.Text & " -g yes " & "-t " & Combo1.ListIndex 
     Else 
      Text1.Text = "-o " & TextPool.Text & ":" & TextPort.Text & " -u " & TextUser.Text & " -p " & TextPass.Text & " -g yes " & "-t " & Combo1.ListIndex 
     End If 
    Else 
     If TextPass.Text = "" Then 
      Text1.Text = "-o " & TextPool.Text & ":" & TextPort.Text & " -u " & TextUser.Text & " -g no " & "-t " & Combo1.ListIndex 
     Else 
      Text1.Text = "-o " & TextPool.Text & ":" & TextPort.Text & " -u " & TextUser.Text & " -p " & TextPass.Text & " -g no " & "-t " & Combo1.ListIndex 
     End If 
    End If 
End Sub 

幫助表示讚賞!或者只是修復我的代碼。

回答

2

因爲你可以選中或取消選中Check1,很顯然,它已啓用,所以您的病情

If Check1.Enabled = True Then 

永遠是正確的。你真正想要做的是看是否Check1檢查,隨着病情

If Check1.Value = 1 Then 
+0

這是行不通的。你測試過了嗎? 「未找到方法或數據成員」。 Check1.Check是否存在? :O – user2404495

+1

沒有測試。這就是我一直檢查是否檢查複選框的方式。用不同的選項編輯我的答案。 – jonhopkins

+0

工作,非常感謝! :) – user2404495

0

所有你需要做的就是改變

check1.enabled =真

。 。into:

check1.value = vbchecked

所以繼承人的結果,(請不要忘記評價我的答案! Thansk!)

Private Sub Command1_Click() 
    If Check1.value = vbChecked Then 
     If TextPass.Text = "" Then 
      Text1.Text = "-o " & TextPool.Text & ":" & TextPort.Text & " -u " & TextUser.Text & " -g yes " & "-t " & Combo1.ListIndex 
     Else 
      Text1.Text = "-o " & TextPool.Text & ":" & TextPort.Text & " -u " & TextUser.Text & " -p " & TextPass.Text & " -g yes " & "-t " & Combo1.ListIndex 
     End If 
    Else 
     If TextPass.Text = "" Then 
      Text1.Text = "-o " & TextPool.Text & ":" & TextPort.Text & " -u " & TextUser.Text & " -g no " & "-t " & Combo1.ListIndex 
     Else 
      Text1.Text = "-o " & TextPool.Text & ":" & TextPort.Text & " -u " & TextUser.Text & " -p " & TextPass.Text & " -g no " & "-t " & Combo1.ListIndex 
     End If 
    End If 
End Sub 
相關問題