CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2012
    Posts
    1

    Really need help please .. radio buttons can not get the resultLabel to show

    Hi all... I have made an application and the code is basically listed below. I been doing this in VB Express 2008... it has 2 input text boxes where the user would put in 2 numbers, and then there are 5 groupboxes with between 4-8 radiobuttons in each. The user would choose 1 radio button per group box, and depending on which radio button is selected then the value of num1 would ioncrease or decrese by a certain amount.

    It runs ok with no errors, just can not the resultlabel to show the answer

    Anyone see why? please and thnak you

    Code:
     'Declares Local Variables
            Dim num1Decimal As Decimal
            Dim num2Decimal As Decimal
            Dim resultLabel As Decimal
    
            'Place the Data in the Variables
            num1Decimal = Val(num1.Text)
            num2Decimal = Val(num1.Text)
    
            'This is the information from the radiobuttons
            ' Create and initialize a GroupBox and a Button control.
            Dim spinGroupBox As New GroupBox
            Dim resultADecimal As Decimal
            Dim spin1b As Decimal
            Select Case True
                Case spin1RadioButton.Checked
                    spin1b = 0.095
                Case spin2RadioButton.Checked
                    spin1b = 0.085
                Case spin3RadioButton.Checked
                    spin1b = 0.08
                Case spin4RadioButton.Checked
                    spin1b = 0.08
                Case spin5RadioButton.Checked
                    spin1b = 0.08
            End Select
            resultADecimal = spin1b
    
            ' Create and initialize a GroupBox and a Button control. 
            Dim windGroupBox As New GroupBox
            Dim wind1b As Decimal
            Dim resultBDecimal As Decimal
            Select Case True
                Case upRadioButton.Checked
                    wind1b = 0.095
                Case ULRadioButton.Checked
                    wind1b = 0.085
                Case urRadioButton.Checked
                    wind1b = 0.075
                Case downRadioButton.Checked
                    wind1b = 0.07
                Case dlRadioButton.Checked
                    wind1b = 0.065
                Case drRadioButton.Checked
                    wind1b = 0.06
                Case leftRadioButton.Checked
                    wind1b = 0.055
                Case rightRadioButton.Checked
                    wind1b = 0.05
    
            End Select
            resultBDecimal = wind1b
    
            ' Create and initialize a GroupBox and a Button control. 
            Dim locationGroupBox As New GroupBox
            Dim location1b As Decimal
            Dim resultCDecimal As Decimal
            Select Case True
                Case fairwayRadioButton.Checked
                    location1b = 0.095
                Case firstCutRadioButton.Checked
                    location1b = 0.085
                Case secondCutRadioButton.Checked
                    location1b = 0.075
                Case deepRadioButton.Checked
                    location1b = 0.07
                Case sandRadioButton.Checked
                    location1b = 0.065
                Case weedsRadioButton.Checked
                    location1b = 0.06
                Case mulchRadioButton.Checked
                    location1b = 0.055
    
            End Select
            resultCDecimal = location1b
    
            ' Create and initialize a GroupBox and a Button control. 
            Dim swingGroupBox As New GroupBox
            Dim swing1b As Decimal
            Dim resultDDecimal As Decimal
            Select Case True
                Case fullRadioButton.Checked
                    swing1b = 0.095
                Case pitchRadioButton.Checked
                    swing1b = 0.085
                Case chipRadioButton.Checked
                    swing1b = 0.075
                Case flopRadioButton.Checked
                    swing1b = 0.07
                Case punchRadioButton.Checked
                    swing1b = 0.065
    
            End Select
            resultDDecimal = swing1b
    
            ' Create and initialize a GroupBox and a Button control. 
            Dim lieGroupBox As New GroupBox
            Dim lie1b As Decimal
            Dim resultEDecimal As Decimal
            Select Case True
                Case lie1RadioButton.Checked
                    lie1b = 0.095
                Case lie2RadioButton.Checked
                    lie1b = 0.085
                Case lie3RadioButton.Checked
                    lie1b = 0.075
                Case lie4RadioButton.Checked
                    lie1b = 0.07
                Case lie5RadioButton.Checked
                    lie1b = 0.065
                Case lie6RadioButton.Checked
                    lie1b = 0.06
                Case lie7RadioButton.Checked
                    lie1b = 0.055
                Case lie8RadioButton.Checked
                    lie1b = 0.05
    
            End Select
            resultEDecimal = lie1b
    
            ' Calculate and Display the Yards to Hole needed.
            resultLabel = num1Decimal + (num1Decimal * resultADecimal) + (num2Decimal * resultBDecimal) + (num1Decimal * resultCDecimal) + (num1Decimal * resultDDecimal) + (num1Decimal * resultEDecimal)

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Really need help please .. radio buttons can not get the resultLabel to show

    You have no code there to display anything.

    If resultLabel is actually a label and you want to display something in it then first you need to drop the definitions from your routine as you are overriding it and defining it as a Decimal.

    To assign the value to the label you would use something like
    Code:
            resultLabel.Text = (num1Decimal + (num1Decimal * resultADecimal) + (num2Decimal * resultBDecimal) + (num1Decimal * resultCDecimal) + (num1Decimal * resultDDecimal) + (num1Decimal * resultEDecimal)).tostring
    Always use [code][/code] tags when posting code.

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

Featured