Conditions evaluation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Z

    Conditions evaluation

    This is really dumb, but it's giving me problems.
    Can't get this ElseIf to get to the next image control to make it visible.
    Dim strRedSox As String
    Dim strYankee As String
    Dim strFull As String

    strRedSox = lstRedSox.Text
    strYankee = lstYankee.Text
    strFull = strRedSox$ & strYankee$

    If strFull$ = PedroJeter Then
    imgPedro.Visibl e = True
    MsgBox "________", vbInformation, "__________ _!"
    ElseIf strFull$ = SchillingJeter Then
    ' imgPedro.Visibl e = False
    imgSchilling.Vi sible = True

    Tried w/o the comment and about six other ways, imgPedro always displays.
    Would a Select Case statement be better, and if so how?
    Thanx.


  • Gemini

    #2
    Re: Conditions evaluation

    Steve Z wrote:
    [color=blue]
    > This is really dumb, but it's giving me problems.
    > Can't get this ElseIf to get to the next image control to make it visible.
    > Dim strRedSox As String
    > Dim strYankee As String
    > Dim strFull As String
    >
    > strRedSox = lstRedSox.Text
    > strYankee = lstYankee.Text
    > strFull = strRedSox$ & strYankee$
    >
    > If strFull$ = PedroJeter Then
    > imgPedro.Visibl e = True
    > MsgBox "________", vbInformation, "__________ _!"
    > ElseIf strFull$ = SchillingJeter Then
    > ' imgPedro.Visibl e = False
    > imgSchilling.Vi sible = True
    >
    > Tried w/o the comment and about six other ways, imgPedro always displays.
    > Would a Select Case statement be better, and if so how?
    > Thanx.
    >[/color]

    Seems like you need to remove the `$' on your strs in the if/then/else
    statement, since you dimmed them w/o the $ (which is preferable anyway)

    Also, I think your PedroJeter and SchillingJeter should be in quotes, as
    right now the program sees them as variable

    Try making sure Option Explicit is on, that way the compiler picks up
    undeclared variables, and thus little errors like this (and spelling
    erros too)

    Scott Zielinski

    Comment

    • Steve Z

      #3
      Re: Conditions evaluation


      "Gemini" <[email protected] g> wrote in message
      news:753c9$4056 154a$d89e2d68$1 [email protected] thenewsgroups.c om...[color=blue][color=green]
      >>[/color]
      > Seems like you need to remove the `$' on your strs in the if/then/else
      > statement, since you dimmed them w/o the $ (which is preferable anyway)
      >
      > Also, I think your PedroJeter and SchillingJeter should be in quotes, as
      > right now the program sees them as variable
      >
      > Try making sure Option Explicit is on, that way the compiler picks up
      > undeclared variables, and thus little errors like this (and spelling
      > erros too)
      >[/color]
      SZ, much appreciated.
      I had thought of Option Explicit, you're right, it does come back with
      PedroJeter as an undeclared variable.
      And removing the designation that the variable accepts a string($) and
      quotes were also tried. When quotes were added nothing happened to the image
      control/MsgBox on execution, program just sits there, no errors.
      Here's the weird part - it works the way it is, the first image control and
      MsgBox display, just the ElseIf fails and the same image control is
      displayed. But it doesn't look like variables are moving correctly with the
      = assignment, the Locals window shows no movement.
      I looked a lot today and couldn't find anything, I'll try again manana.


      Comment

      • Gemini

        #4
        Re: Conditions evaluation

        Steve Z wrote:[color=blue]
        > SZ, much appreciated.
        > I had thought of Option Explicit, you're right, it does come back with
        > PedroJeter as an undeclared variable.
        > And removing the designation that the variable accepts a string($) and
        > quotes were also tried. When quotes were added nothing happened to the image
        > control/MsgBox on execution, program just sits there, no errors.
        > Here's the weird part - it works the way it is, the first image control and
        > MsgBox display, just the ElseIf fails and the same image control is
        > displayed. But it doesn't look like variables are moving correctly with the
        > = assignment, the Locals window shows no movement.
        > I looked a lot today and couldn't find anything, I'll try again manana.
        >[/color]

        Make sure that 1st line in the ELSEIF statement is uncommented.

        Also are these in the form_load sequence?
        strRedSox = lstRedSox.Text
        strYankee = lstYankee.Text
        strFull = strRedSox$ & strYankee$

        If so, when the program is executed, you haven't selected anything for
        the listboxes to return (in order for strRedSox= "Pedro" you have to
        have Pedro highlighted in the listbox *before* those varibles are
        initialized; which means you should set that code, and it appears maybe
        all of the code you posted, in the commandbutton_c lick event procedure.

        Scott Zielinski

        Comment

        • Steve Z

          #5
          Re: Conditions evaluation


          "Gemini" <[email protected] g> wrote in message
          news:23148$4057 3382$d89e2d68$2 [email protected] thenewsgroups.c om...[color=blue][color=green]
          > >[/color]
          >
          > Make sure that 1st line in the ELSEIF statement is uncommented.
          >
          > Also are these in the form_load sequence?
          > strRedSox = lstRedSox.Text
          > strYankee = lstYankee.Text
          > strFull = strRedSox$ & strYankee$
          >
          > If so, when the program is executed, you haven't selected anything for
          > the listboxes to return (in order for strRedSox= "Pedro" you have to
          > have Pedro highlighted in the listbox *before* those varibles are
          > initialized; which means you should set that code, and it appears maybe
          > all of the code you posted, in the commandbutton_c lick event procedure.
          >[/color]
          My bad, this is click event procedure code.
          There's some check boxes that fill the listboxes prior to the command click
          event.
          Still confused, I tried a couple things today, Select Case's and nesting the
          If Then's, everything works just like the initial code, the first img
          control displays no matter the change in condition.
          Still working on it....



          Comment

          Working...