0

如果未选中复选框,为什么文本框中的文本不会更改?如果未选中,则文本框的文本应具有“-g no”,但单击 Command1 时不会更改。有什么解决办法吗?可能是一些非常简单的事情,但我只是没有成功。:\

我的代码:

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

帮助表示赞赏!或者然后只是修复我的代码。

4

2 回答 2

2

因为可以勾选或者取消勾选Check1,很明显是启用的,所以你的条件

If Check1.Enabled = True Then

永远都是真的。你真正想做的是看看是否Check1检查,有条件

If Check1.Value = 1 Then
于 2013-06-21T16:03:54.387 回答
0

你所要做的就是改变

check1.enabled = true

.. 进入:

check1.value = vbchecked

所以这是结果,(请不要忘记评价我的答案!谢谢!)

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
于 2013-06-24T22:03:55.300 回答