Public Class Form1 Private Sub SummaryBut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SummaryBut.Click Dim PiecesProdTxtbox As Integer Dim TotalPayTxtbox As Integer Dim PiecesCostTxtbox As Integer Dim AvgPayPerPersonTxtbox As Integer Dim MsgCenterTxtbox As String 'this is a simple case select procedure to determine 'the cost of each piece. Select Case PiecesProdTxtbox Case "PiecesProdTxtbox <= 199" PiecesCostTxtbox = ".50" Case "PiecesProdTxtbox <= 399" PiecesCostTxtbox = ".55" Case "PiecesProdTxtbox <= 599" PiecesCostTxtbox = ".60" Case "PiecesProdTxtbox >= 600" PiecesCostTxtbox = ".65" Case Else MsgCenterTxtbox = "Invalid Input" End Select 'this next line is to multiply the piece cost times the 'pieces produced resulting in the total Pay for said pieceworker PiecesProdTxtbox * PiecesCostTxtbox = TotalPayTxtbox 'this line of code divides Total Pay by Total number of pieces 'to get Average pay per pieceworker. TotalPayTxtbox / PiecesProdTxtbox = AvgPayPerPersonTxtbox End Sub Private Sub CalcBut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalcBut.Click Dim PiecesCostTxtbox As Integer Dim PiecesProdTxtbox As Integer Dim MsgCenterTxtbox As String Dim TotalDollarsEarnedTxtbox As Decimal Select Case PiecesProdTxtbox Case "PiecesProdTxtbox <= 199" PiecesCostTxtbox = ".50" Case "PiecesProdTxtbox <= 399" PiecesCostTxtbox = ".55" Case "PiecesProdTxtbox <= 599" PiecesCostTxtbox = ".60" Case "PiecesProdTxtbox >= 600" PiecesCostTxtbox = ".65" Case Else MsgCenterTxtbox = "Invalid Input" End Select (PiecesCostTxtbox * PiecesProdTxtbox = TotalDollarsEarnedTxtbox) 'I really wanna find a way to keep the case structure from being enabled 'in this button's code since it is already used with the summary button End Sub Private Sub ClearBut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearBut.Click TotalDollarsEarnedTxtbox.Clear() NameTxtbox.Clear() PiecesProdTxtbox.Clear() End Sub Private Sub ClearAllBut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearAllBut.Click PiecesCostTxtbox.Clear() TotalPayTxtbox.Clear() AvgPayPerPersonTxtbox.Clear() End Sub End Class
help with the syntax of my codeI wanna fix the syntax but Im no professional when it comes to vb.net
Page 1 of 1
7 Replies - 422 Views - Last Post: 24 January 2010 - 09:58 PM
#1
help with the syntax of my code
Posted 24 January 2010 - 12:45 PM
I was working on a calculator for pieceworkers...I got most of the code implemented but I came up with build errors that would not let me continue, since I don't know how to fix the build errors, I am stuck. Any help would be appreciated...
Replies To: help with the syntax of my code
#2
Re: help with the syntax of my code
Posted 24 January 2010 - 12:52 PM
Please post the error(s). We can't suggest how to fix them if we don't know what they are.
This post has been edited by n8wxs: 24 January 2010 - 12:52 PM
#3
Re: help with the syntax of my code
Posted 24 January 2010 - 01:12 PM
Best I can tell, I think I'm mainly having issues with the conversion of my data types. It keeps telling me
Invalid Cast Exception was unhandled
This post has been edited by kweef19: 24 January 2010 - 01:15 PM
#4
Re: help with the syntax of my code
Posted 24 January 2010 - 04:44 PM
I guess I'll look at a few tuts and see if I can fix some of the problems...
#5
Re: help with the syntax of my code
Posted 24 January 2010 - 06:22 PM
I think your problem is here:
and here:
and here:
Should be:
and
and
(PiecesCostTxtbox * PiecesProdTxtbox = TotalDollarsEarnedTxtbox)
and here:
TotalPayTxtbox / PiecesProdTxtbox = AvgPayPerPersonTxtbox
and here:
TotalPayTxtbox / PiecesProdTxtbox = AvgPayPerPersonTxtbox
Should be:
TotalDollarsEarnedTxtbox = PiecesCostTxtbox * PiecesProdTxtbox
and
AvgPayPerPersonTxtbox = TotalPayTxtbox / PiecesProdTxtbox
and
AvgPayPerPersonTxtbox = TotalPayTxtbox / PiecesProdTxtbox
#6
Re: help with the syntax of my code
Posted 24 January 2010 - 07:24 PM
Your coding problems stem from an a basic misunderstanding of textboxes, to you (as a human) see a number but to the computer that same textboxes contains a bunch of characters (a string).
Strings are different to numbers (Integer & Double are examples of different Types of Number vb.net understands)
So you need to convert the textbox contents in to number type, this is called parseing.
See: My BlogPost on the subject
Strings are different to numbers (Integer & Double are examples of different Types of Number vb.net understands)
So you need to convert the textbox contents in to number type, this is called parseing.
Dim MyNumber As Double If Double.TryParse(Textbox1.Text,MyNumber) Then ' MyNumber contains a valid double Else ' The text (string) can not be parsed as a double. EndIf
See: My BlogPost on the subject
#7
Re: help with the syntax of my code
Posted 24 January 2010 - 09:52 PM
Could you possibly point me in the right direction to a tut of parsing so I can try and learn how to use it???
#8
Re: help with the syntax of my code
Posted 24 January 2010 - 09:58 PM
There are two in my previous post;- the code and the blog post.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|