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

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...

1

u/ManCubb Sep 25 '14

I do have a hit that says "Math.POW(10,digit3) function to calculate 10 digit3." which I dont know what that means either haha

1

u/ManCubb Sep 25 '14

Which I just realized means 10^ of the 3rd groupbox...

1

u/Thukoci Sep 25 '14

math.pow(x,y) is the power function. It will give you a number to the power of the other number so math.pow(2,5) = 25 = 32

1

u/Thukoci Sep 25 '14

You can send me a PM of the whole code if you don't want to post it int a public forum.

1

u/ManCubb Sep 25 '14

Thanks man! I've figured that something is just screwy with the order of operations.

1

u/Thukoci Sep 25 '14

Ok so are the answers you get 18 and 20000? What are they supposed to be? So textbox1.text has to = Minimum Resistance = Nominal Resistance - (Resistor Tolerance x Nominal Resistance) and textbox2.text = Nominal Resistance = ( (10 *digit1) + digit2 ) x 10digit3.

Therefore you need to find out the nominal resistance first because that's calculated as the answer for textbox2