Results 1 to 8 of 8

Thread: Select Case Statement

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    27

    Resolved Select Case Statement

    Using a Select Case Statement to determine customer's Status. Either Retail or wholeSale. is the correct code

    VB Code
    ----------------
    Private Sub ProcessOperationRadioButtons(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles WholeRadioButton.Click
    Dim intRetail, intWholesaler As Integer

    'display appropriate operator
    Select Case True
    Case 1
    Me.WholeRadioButton.Checked = intWholesaler
    Case Else
    Me.RetailRadioButton.Checked = intRetail
    End Select

    End Sub
    ---------------
    end code
    Last edited by terrytemes; Feb 2nd, 2005 at 05:25 AM. Reason: resolved

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: Select Case Statement

    Hi,

    No. But the correct method is not clear from your posting. I think you want

    VB Code:
    1. Select Case True
    2.   Case Me.WholeRadioButton.Checked
    3.     MessageBox.Show("Wholesaler")
    4.   Case Else
    5.     MessageBox.Show("Retailer")
    6. End Select
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    27

    Re: Select Case Statement

    Thanks that is what I orginally thought. By selecting either wholesale or Retail the price changes. So I was try to figure out how to then calculate different prices charged in an If then statement.

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: Select Case Statement

    Hi,

    OK, so:

    VB Code:
    1. Select Case True
    2.   Case Me.WholeRadioButton.Checked
    3.     ChargePrice=WholesalePrice
    4.   Case Else
    5.     ChargePrice = RetailPrice
    6. End Select
    7. Return ChargePrice
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  5. #5
    PowerPoster SuperSparks's Avatar
    Join Date
    May 2003
    Location
    London, England
    Posts
    265

    Re: Select Case Statement

    But you wouldn't normally use Select Case where there are only two possibilities, If...Then...Else would be more usual. Select Case is really meant for situations where there are many choices. Though it will work perfectly well.
    Nick.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    27

    Re: Select Case Statement

    Thanks Taxes, you really helped. It took me awhile studying your code to understand it. It was a big help for this newbie. I agree with you Super Sparks, this bit of code was only meant to help me learn how to combine the select case with an IF Else statement using radio buttons.
    Last edited by terrytemes; Feb 2nd, 2005 at 05:24 AM. Reason: Resloved

  7. #7
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: Select Case Statement

    Hi,

    The excerpt of code you previously posted is not the same as you actually used.

    You cannot check for numerical entry in the way you are trying. Look in the code bank at

    http://www.vbforums.com/showthread.php?t=314936
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  8. #8
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: Select Case Statement

    Quote Originally Posted by SuperSparks
    But you wouldn't normally use Select Case where there are only two possibilities, If...Then...Else would be more usual. Select Case is really meant for situations where there are many choices. Though it will work perfectly well.
    Agreed, but I was just staying with what he produced.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

Posting Permissions

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



Click Here to Expand Forum to Full Width