G
Guest
I'm new VB and programming all together, but I'm getting he hang of it.
My question is;
I'm writting a program to figure square feet and yards when the user inputs
"Length in feet and inch ( seperate boxes), Width in feet and inches
(seperate boxes), and thickness in feet and inches (all so in seperate
boxes). I haven't quit figured out the split function yet to use a single
text box for each. Anyways, when I enter data in each box; eg.
Length 2' 0"
Width 2' 0"
Thickness 0' 4"
my program works and figures out the correct answer. But when I enter it
differently, like this;
Lenght 2' not entering inches leaving box empty
Widht 2' not entering inches leaving box empty
Thickness not entering feet leaving box empty but entering 4"
it gives me an error "Cast from string " " to type 'Integer' is not valid."
Here is some of what Ive written.
Public LFeet, WFeet, TFeet As Integer
Public LInch, WInch, TInch As Integer
Public SqrFeet, Yard As Integer
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCompute.Click
If Me.txtLInch.Text = " " Then TInch = 0
If Me.txtWInch.Text = " " Then WInch = 0
If Me.txtTFeet.Text = " " Then TInch = 0
Me.LFeet = Me.txtLFeet.Text
Me.LInch = Me.txtLInch.Text
Me.WFeet = Me.txtWFeet.Text
Me.WInch = Me.txtWInch.Text
Me.TFeet = Me.txtTFeet.Text
Me.TInch = Me.txtTInch.Text
If Me.WInch = 0 And Me.LInch = 0 Then Me.txtSqrFeet.Text = Me.LFeet
* Me.WFeet Else
Me.txtSqrFeet.Text = (Me.LFeet + (Me.LInch / 12)) * (Me.WFeet +
(Me.WInch / 12))
Me.SqrFeet = Me.txtSqrFeet.Text
If Me.TFeet = 0 Then Me.txtYard.Text = (Me.SqrFeet * (Me.TInch / 12)
/ 27) Else
Me.txtYard.Text = (Me.SqrFeet * (Me.TFeet + (Me.TInch / 12))) / 27
End Sub
I know that I'm using the wrong variables here, I can't quit figure it out
though.
Thanks to Anyone Who Replies.
My question is;
I'm writting a program to figure square feet and yards when the user inputs
"Length in feet and inch ( seperate boxes), Width in feet and inches
(seperate boxes), and thickness in feet and inches (all so in seperate
boxes). I haven't quit figured out the split function yet to use a single
text box for each. Anyways, when I enter data in each box; eg.
Length 2' 0"
Width 2' 0"
Thickness 0' 4"
my program works and figures out the correct answer. But when I enter it
differently, like this;
Lenght 2' not entering inches leaving box empty
Widht 2' not entering inches leaving box empty
Thickness not entering feet leaving box empty but entering 4"
it gives me an error "Cast from string " " to type 'Integer' is not valid."
Here is some of what Ive written.
Public LFeet, WFeet, TFeet As Integer
Public LInch, WInch, TInch As Integer
Public SqrFeet, Yard As Integer
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCompute.Click
If Me.txtLInch.Text = " " Then TInch = 0
If Me.txtWInch.Text = " " Then WInch = 0
If Me.txtTFeet.Text = " " Then TInch = 0
Me.LFeet = Me.txtLFeet.Text
Me.LInch = Me.txtLInch.Text
Me.WFeet = Me.txtWFeet.Text
Me.WInch = Me.txtWInch.Text
Me.TFeet = Me.txtTFeet.Text
Me.TInch = Me.txtTInch.Text
If Me.WInch = 0 And Me.LInch = 0 Then Me.txtSqrFeet.Text = Me.LFeet
* Me.WFeet Else
Me.txtSqrFeet.Text = (Me.LFeet + (Me.LInch / 12)) * (Me.WFeet +
(Me.WInch / 12))
Me.SqrFeet = Me.txtSqrFeet.Text
If Me.TFeet = 0 Then Me.txtYard.Text = (Me.SqrFeet * (Me.TInch / 12)
/ 27) Else
Me.txtYard.Text = (Me.SqrFeet * (Me.TFeet + (Me.TInch / 12))) / 27
End Sub
I know that I'm using the wrong variables here, I can't quit figure it out
though.
Thanks to Anyone Who Replies.