none
If then conditions RRS feed

  • Question

  • I believe I asked this question in the wrong section previously. I was directed here. 

    My previous question was asked here:

    https://social.msdn.microsoft.com/Forums/en-US/4b02cfa0-a63d-4adb-8ae2-6c2fc60f42ff/need-help-with-if-then-conditions?forum=vbgeneral


    "I want the code to run and check the text value of the combobox and if the value is 27, 28, 29, or 30. I want the code to check another section with 10 text boxes if 27, 28, 29, or 30 is chosen in the combo box. If the checkweigh section is not filled out then I want a single error message to pop up stating to finish filling that section out. Currently, the code only checks the first checkweigh1 and if that text box has a value it does not check the other code.

    Here is my code:

    LineCombo.SetFocus
    If LineCombo.Text >= 27 And LineCombo.Text <= 30 Then
        CheckWeigh1.SetFocus
        If CheckWeigh1.Text = "" Then
        CheckWeigh2.SetFocus
        ElseIf CheckWeigh2.Text = "" Then
        CheckWeigh3.SetFocus
        ElseIf CheckWeigh3.Text = "" Then
        CheckWeigh4.SetFocus
        ElseIf CheckWeigh4.Text = "" Then
        CheckWeigh5.SetFocus
        ElseIf CheckWeigh5.Text = "" Then
        CheckWeigh6.SetFocus
        ElseIf CheckWeigh6.Text = "" Then
        CheckWeigh7.SetFocus
        ElseIf CheckWeigh7.Text = "" Then
        CheckWeigh8.SetFocus
        ElseIf CheckWeigh8.Text = "" Then
        CheckWeigh9.SetFocus
        ElseIf CheckWeigh9.Text = "" Then
        CheckWeigh10.SetFocus
        ElseIf CheckWeigh10.Text = "" Then
        err = err + 1
                MsgBox "Please finish filling out the Check Weigher Section!"

    End If"

    I believe the formatting would be different, but based on the answer in the comments, how would I write the code for Applications of VBA??

    Thursday, March 17, 2016 12:35 AM

All replies

  • Hi,

    Please explain the further detail.
      Do you use Excel/Word...??
      What does it mean by "section"?
      What kind of control "CheckWeighxx" is?
      and more...

    Regards.
    Thursday, March 17, 2016 3:12 AM