0
Answer

Using tabs to display data on multiple tabs, but I can only get VB calulations to work on Tab1

Nathan Leister

Nathan Leister

15y
3.2k
1

Hello,

I'm new to VB & Programming and I'm trying to create my first app that reads/writes from SQL.  I have form that has a TextBox and a tabcontrol with 8 tabs and I use the textbox as a parameter to pass to my SQL and return the selection to my form and Tabs.

On tabpage1 I can calculate what I need and assign it to a read only textbox

On tabPage2 I want to do the same but I keep getting a an error "Format Exception was unhandled , Input string was not in the right format"

The same goes for all my other tabs.

Why does it work on tab1 but will not work for any other tab.  I can even move my textboxes from tab2 over to tab1 and the format error goes away and it works fine.

Here is my code:

Public Function Testscalc() As Double

'Tab page1

Me.txtOTensile4.Text = Convert.ToString(Median(Convert.ToDouble(Me.txtOTensile1.Text), Convert.ToDouble(Me.txtOTensile2.Text), Convert.ToDouble(Me.txtOTensile3.Text))).ToString

Me.txtOElong4.Text = Convert.ToString(Median(Convert.ToDouble(Me.txtOElong1.Text), Convert.ToDouble(Me.txtOElong2.Text), Convert.ToDouble(Me.txtOElong3.Text))).ToString

Me.txtODuro4.Text = Convert.ToString((Convert.ToDouble(Me.txtODuro1.Text) + Convert.ToDouble(Me.txtODuro2.Text) + Convert.ToDouble(Me.txtODuro3.Text)) / 3).ToString

'Tab Page2

Me.txtATensile4.Text = Convert.ToString(Median(Convert.ToDouble(Me.txtATensile1.Text), Convert.ToDouble(Me.txtATensile2.Text), Convert.ToDouble(Me.txtATensile3.Text))).ToString

 

Me.txtAElong4.Text = Convert.ToString(Median(Convert.ToDouble(txtAElong1.Text), Convert.ToDouble(Me.txtAElong2.Text), Convert.ToDouble(Me.txtAElong3.Text))).ToString

Me.txtADuro4.Text = Convert.ToString((Convert.ToDouble(Me.txtADuro1.Text) + Convert.ToDouble(Me.txtADuro2.Text) + Convert.ToDouble(Me.txtADuro3.Text)) / 3).ToString

'Tab Page3

Me.txtWImmersionD.Text = Convert.ToString((Convert.ToDouble(Me.txtWImmersionA.Text) + Convert.ToDouble(Me.txtWImmersionB.Text) + Convert.ToDouble(Me.txtWImmersionC.Text)) / 3).ToString

End Function

 

Public Shared Function Median(ByVal Num1 As Double, ByVal Num2 As Double, ByVal Num3 As Double) As Double

Dim numList As New List(Of Double)

numList.Add(Num1)

numList.Add(Num2)

numList.Add(Num3)

numList.Sort()

Return numList(1)

End Function

 

 

 

 

Next Recommended Forum