Jump to content

VB Variable Problem

I'm having an issue using VB. When I just multiply the two variables I have an issue of the result variable not changing when the parameters are different.

eg.

Num1 = 2

Num2 = 5

 

Res= 10,

now when I change the parameters in the still running program it will give me an answer like this;

 

Num1 = 2

Num2= 10

Res= 10

 

I have isolated the problem to res variable.

Any ideas?

Public Class Form1    Dim Num1 As Double    Dim Num2 As Double    Dim V1 As Double    Dim V2 As Double    Dim EngUnit1 As Double    Dim EngUnit2 As Double    Dim slipGauageValue As Double    Private Sub bttnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnCalc.Click        'Checking for numbers'        Me.txtCaliberation.Clear()        Application.DoEvents()        If IsNumeric(TxtBxEngUnit1.Text) Then            EngUnit1 = TxtBxEngUnit1.Text        Else            MsgBox("Please enter a Number in Eng Unit 1")        End If        If IsNumeric(TxtBxEngUnit2.Text) Then            EngUnit2 = TxtBxEngUnit2.Text        Else            MsgBox("Please enter a Number in Eng Unit 2")        End If        Try            slipGauageValue = CBxSlipValue.Text        Catch Exc As InvalidCastException            MsgBox("Please choose a Number form the list")        End Try        If IsNumeric(txtVolt1.Text) Then            V1 = txtVolt1.Text        Else            MsgBox("Please enter a number in Voltage Reading 1")        End If        If IsNumeric(txtVolt2.Text) Then            V2 = txtVolt2.Text        Else            MsgBox("Please enter a number in Voltage Reading 2")        End If        Num1 = (((V1) - (V2)) / ((EngUnit1) - (EngUnit2)))        Num2 = (slipGauageValue / ((V1) - (V2)))        Dim Res = Num1 * Num2        txtCaliberation.Text = Res          End Sub

My hatred of VB grows larger each day.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Never mind, figured it out, the voltage difference (V1 & V2) equal themselves out :P

I still hate VB though haah

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×