Results 1 to 7 of 7

Thread: [RESOLVED] Program help... checkbox?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Location
    Ireland
    Posts
    85

    Resolved [RESOLVED] Program help... checkbox?

    In my program, I can place an order for glasses.

    To do this, I have 4 text boxes:

    StockNumber: [12345]
    GlassOrPlastic: [Glass/Plastic]
    ScratchCoating: [Yes/No]
    UVFilter: [Yes/No]

    Currently, it works fine... BUT I need to type in Glass or Plastic, I need to type Yes/No and same for each thing, wondering would checkboxes be more effecient or how would I do it?

    How do I even use checkboxes to get the same values...
    (If I type in Glass it adds €30 to the price, if I type in Plastic only €15 is added...)
    So if a Yes answer = €20 and a No = €10

    How can I do that with checkboxes or whatever...


    My code for when I click the order button, myAddNew just adds my information in..

    ok Code:
    1. Private Sub OrderButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OrderButton.Click
    2.         Dim myValue As Integer ' Base value of frames
    3.         Dim myValue1 As Integer ' Glass or plastic value
    4.         Dim myValue2 As Integer ' Scratch Coating value
    5.         Dim myValue3 As Integer ' UV value
    6.         Dim totalCost As Integer ' Total value
    7.         Dim deposit As Integer ' Deposit value, 20% of total
    8.  
    9.         myValue = 50 'Base value of frames, always 50
    10.  
    11.         Select Case GPTextBox.Text
    12.             Case "Glass"
    13.                 myValue1 = 30
    14.             Case "Plastic"
    15.                 myValue1 = 15
    16.         End Select
    17.  
    18.         Select Case ScratchTextBox.Text
    19.             Case "Yes"
    20.                 myValue2 = 10
    21.             Case "No"
    22.                 myValue2 = 0
    23.         End Select
    24.  
    25.         Select Case UVTextBox.Text
    26.             Case "Yes"
    27.                 myValue3 = 15
    28.             Case "No"
    29.                 myValue3 = 0
    30.         End Select
    31.  
    32.  
    33.  
    34.         totalCost = myValue + myValue1 + myValue2 + myValue3 'Gets total by adding all values
    35.         deposit = totalCost * 0.2 'Divides total by 0.2 to find the 20% deposit
    36.  
    37.         TextBox1.Text = totalCost 'Displays total
    38.         TextBox2.Text = deposit 'Displays deposit
    39.         TextBox3.Text = totalCost - deposit 'Subtracts the deposit from total, to find balance
    40.  
    41.         PrintButton.Enabled = True
    42.         ViewButton.Enabled = True
    43.         myAddNew(8) 'CALLS ADDNEW METHOD WHEN ADD BUTTON IS CLICKED
    44.  
    45.  
    46.  
    47.     End Sub
    Last edited by Kielo; Mar 24th, 2010 at 08:24 AM. Reason: code edit

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Program help... checkbox?

    I would place a grouopboxe on the form for Glass/Plastic (Glass Type) in that group box use two radiobutton control (that way only one can be choisen) 1 for Glass the other for Plastic

    as for the Others I would use checkboxes that say: Add UVFitler (if checked then Yes other wise No)
    and the other says: Add Scratch Coating (if checked then Yes other wise No)

    The database would hold a True/False value for the last two values the Lens Type would hold a smallint vaule 1 for Glass 2 for Plastic
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Location
    Ireland
    Posts
    85

    Re: Program help... checkbox?

    Sound good, what way can I code that then to do the same thing it's doing now...

    Sorry for asking that, but I'm crap with anything besides textboxes

  4. #4
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: Program help... checkbox?

    Personally, I would use a ComboBox. Saves space.

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  5. #5
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Program help... checkbox?

    Show some code and I'll help

    Look at checkbox.Checked
    and
    radiobutton.Check

    status
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Location
    Ireland
    Posts
    85

    Re: Program help... checkbox?

    I'll tackle that now, thanks!

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Location
    Ireland
    Posts
    85

    Re: Program help... checkbox?

    vb Code:
    1. If GlassRadioButton.Checked = True Then
    2.  
    3.             myValue2 = 30
    4.  
    5.         ElseIf PlasticRadioButton.Checked = True Then
    6.  
    7.             myValue2 = 15
    8.  
    9.         End If

    Works a charm, thanks again Gary

Tags for this Thread

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