+ Reply to Thread
Results 1 to 6 of 6

Apples or pears

  1. #1
    gregork
    Guest

    Apples or pears

    Hi could someone show me the correct way of writing this code:

    If Me.TextBox1.Text = "Apples" or "pears" Then
    Unload Me
    UserForm4.Show
    End If

    thanks
    GK



  2. #2
    Leo Heuser
    Guest

    Re: Apples or pears

    Hi

    Try this one:

    If Ucase(Me.TextBox1.Text) = "APPLES" Or _
    Ucase(Me.TextBox1.Text) = "PEARS" Then
    Unload Me
    UserForm4.Show
    End If

    The use of Ucase() means, that the user can
    enter any combination of upper- and/or lower case
    in the text box.

    --
    Best Regards
    Leo Heuser

    Followup to newsgroup only please.

    "gregork" <[email protected]> skrev i en meddelelse
    news:[email protected]...
    > Hi could someone show me the correct way of writing this code:
    >
    > If Me.TextBox1.Text = "Apples" or "pears" Then
    > Unload Me
    > UserForm4.Show
    > End If
    >
    > thanks
    > GK
    >
    >




  3. #3
    gregork
    Guest

    Re: Apples or pears

    Thanks for the reply. Can't get it to work though. Not sure why?

    cheers
    GK

    "Leo Heuser" <[email protected]> wrote in message
    news:[email protected]...
    > Hi
    >
    > Try this one:
    >
    > If Ucase(Me.TextBox1.Text) = "APPLES" Or _
    > Ucase(Me.TextBox1.Text) = "PEARS" Then
    > Unload Me
    > UserForm4.Show
    > End If
    >
    > The use of Ucase() means, that the user can
    > enter any combination of upper- and/or lower case
    > in the text box.
    >
    > --
    > Best Regards
    > Leo Heuser
    >
    > Followup to newsgroup only please.
    >
    > "gregork" <[email protected]> skrev i en meddelelse
    > news:[email protected]...
    > > Hi could someone show me the correct way of writing this code:
    > >
    > > If Me.TextBox1.Text = "Apples" or "pears" Then
    > > Unload Me
    > > UserForm4.Show
    > > End If
    > >
    > > thanks
    > > GK
    > >
    > >

    >
    >




  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Gregork,

    Try this:

    With Me.TextBox1
    If .Text = "Apples" or .Text = "pears" Then
    Me.Hide
    UserForm4.Show
    End If
    End With

    Unload Me


    _________________________________________________________________

    If you want your code be insensitive to case, you should use Leo's suggestion. The main problem is you were Unloading your form. This removes it from memory and frees all resources associated with the form. Hiding will keep it memory but not displayed. I suspect the your form is modal. Only one form can be modal at time. So to display UserForm4, Me has to reliquish control either by being hidden or unloaded.

    All the best to you,
    Leith Ross

  5. #5
    Tom Ogilvy
    Guest

    Re: Apples or pears

    If instr(1,Me.Textbox1.Text,"apples",vbTextcompare) > 0 or _
    instr(1,Me.Textbox1.Text,"pears",vbTextcompare) > 0 then
    Unload Me
    Userform4.Show
    End if

    --
    Regards,
    Tom Ogilvy


    "Leo Heuser" <[email protected]> wrote in message
    news:[email protected]...
    > Hi
    >
    > Try this one:
    >
    > If Ucase(Me.TextBox1.Text) = "APPLES" Or _
    > Ucase(Me.TextBox1.Text) = "PEARS" Then
    > Unload Me
    > UserForm4.Show
    > End If
    >
    > The use of Ucase() means, that the user can
    > enter any combination of upper- and/or lower case
    > in the text box.
    >
    > --
    > Best Regards
    > Leo Heuser
    >
    > Followup to newsgroup only please.
    >
    > "gregork" <[email protected]> skrev i en meddelelse
    > news:[email protected]...
    > > Hi could someone show me the correct way of writing this code:
    > >
    > > If Me.TextBox1.Text = "Apples" or "pears" Then
    > > Unload Me
    > > UserForm4.Show
    > > End If
    > >
    > > thanks
    > > GK
    > >
    > >

    >
    >




  6. #6
    gregork
    Guest

    Re: Apples or pears

    Works perfectly thanks Tom

    Regards
    GK

    "Tom Ogilvy" <[email protected]> wrote in message
    news:%[email protected]...
    > If instr(1,Me.Textbox1.Text,"apples",vbTextcompare) > 0 or _
    > instr(1,Me.Textbox1.Text,"pears",vbTextcompare) > 0 then
    > Unload Me
    > Userform4.Show
    > End if
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Leo Heuser" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi
    > >
    > > Try this one:
    > >
    > > If Ucase(Me.TextBox1.Text) = "APPLES" Or _
    > > Ucase(Me.TextBox1.Text) = "PEARS" Then
    > > Unload Me
    > > UserForm4.Show
    > > End If
    > >
    > > The use of Ucase() means, that the user can
    > > enter any combination of upper- and/or lower case
    > > in the text box.
    > >
    > > --
    > > Best Regards
    > > Leo Heuser
    > >
    > > Followup to newsgroup only please.
    > >
    > > "gregork" <[email protected]> skrev i en meddelelse
    > > news:[email protected]...
    > > > Hi could someone show me the correct way of writing this code:
    > > >
    > > > If Me.TextBox1.Text = "Apples" or "pears" Then
    > > > Unload Me
    > > > UserForm4.Show
    > > > End If
    > > >
    > > > thanks
    > > > GK
    > > >
    > > >

    > >
    > >

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1