Search code examples
if-statementvb6

Range check logic?


How do I code this in VB6. I almost got it already but I don't know how to put it all together. I am doing this in VB6.

If Incometxt >= 20962 Then StatusLbl = "Low-income class"
ElseIf Incometxt <= 20963 Then StatusLbl = "Lower middle-income class"
ElseIf Incometxt <= 41925 Then StatusLbl = "Middle middle-income class"
ElseIf Incometxt <= 73368 Then StatusLbl = "Upper middle-income class"
ElseIf Incometxt <= 125773 && = 2096200 Then StatusLbl = "Upper-income class"
Else Incometxt > 2096201 Then StatusLbl = "Rich"

I think the mistake happened on line 5 and 6 of the code I gave above.


Solution

  • Try this:

    If Incometxt <= 20962 Then
        StatusLbl = "Low-income class"
    ElseIf Incometxt >= 20963 And Incometxt <= 41924 Then
        StatusLbl = "Lower middle-income class"
    ElseIf Incometxt >= 41925 And Incometxt <= 73367 Then
        StatusLbl = "Middle middle-income class"
    ElseIf Incometxt >= 73368 And Incometxt <= 125772 Then
        StatusLbl = "Upper middle-income class"
    ElseIf Incometxt >= 125773 And Incometxt <= 2096200 Then
        StatusLbl = "Upper-income class"
    Else
        StatusLbl = "Rich"
    End If