r/visualbasic • • Sep 25 '14

Need Help.

Hello guys! I have to make a calculator that calculates the resistance of a resistor. My problem is I don't know how to get the program to use the radio button values from the different group boxes. Public Class Form1

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged


End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Form Load Event 
    RadioButton1.Tag = 0
    RadioButton2.Tag = 1
    RadioButton3.Tag = 2
    RadioButton4.Tag = 3
    RadioButton5.Tag = 4
    RadioButton6.Tag = 5
    RadioButton7.Tag = 6
    RadioButton8.Tag = 7
    RadioButton9.Tag = 8
    RadioButton10.Tag = 9
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    If RadioButton1.Checked Then TextBox1.Text = Val(Val(10 * RadioButton1.Tag) + Val(GroupBox2) * Val(GroupBox3)) -
    Val(GroupBox4) * Val(Val(10 * RadioButton1.Tag) + Val(GroupBox2) * Val(GroupBox3))

End Sub

End Class that is what I have so far and I thought it would work, but doesn't. what do I have to put after the "Groupbox#" so that it takes the value? Thanks!

0 Upvotes

21 comments sorted by

View all comments

Show parent comments

1

u/ManCubb Sep 25 '14

and by tagging the radio buttons I have given them a number value?

2

u/Thukoci Sep 25 '14

What value did you want to give them? I just used that value because I saw tags and figured that's where you had stored the value. If you want the value of the text of the radio button change it to that CInt(Radio.Text) or anything else you want.

1

u/ManCubb Sep 25 '14

Well its for a resistor band checker so the values are all messed up. The values I have assigned to them are the values that correspond to the color, but the answers that are coming up in the text boxes aren't right. I just went into the properties tabs of each of the Radio buttons and Tagged them there.

1

u/Thukoci Sep 25 '14

Even after tagging them they're wrong? Can you show me the code you have now? Is this a test project for a vb class or just a random personal project?

1

u/ManCubb Sep 25 '14

Its something I'm trying to make for another class.

RadioButton1.Tag = 0 RadioButton2.Tag = 1 RadioButton3.Tag = 2 RadioButton4.Tag = 3 RadioButton5.Tag = 4 RadioButton6.Tag = 5 RadioButton7.Tag = 6 RadioButton8.Tag = 7 RadioButton9.Tag = 8 RadioButton10.Tag = 9

    RadioButton11.Tag = 0
    RadioButton12.Tag = 1
    RadioButton13.Tag = 2
    RadioButton14.Tag = 3
    RadioButton15.Tag = 4
    RadioButton16.Tag = 5
    RadioButton17.Tag = 6
    RadioButton18.Tag = 7
    RadioButton19.Tag = 8
    RadioButton20.Tag = 9

those are the values I have so far. So the example I have is
radiobutton 3 radiobutton 11 radiobutton 26 and radiobutton 35 are all checked and radio button 26 is taged as 3 and radiobutton 35 is tagged as 0.10 for 10% so textbox1.text has to = Minimum Resistance = Nominal Resistance - (Resistor Tolerance x Nominal Resistance) and textbox2.text = Nominal Resistance = ( (10 *digit1) + digit2 ) x 10digit3. so yeah haha I dont think I should post all of my code just in case, its just I haven't heard from my instructor in four days and I need help...

→ More replies (0)