Hello, I am stuck. I am supposed
to validate the input data type into txtBox before allowitn the program to continue but I keep getting too many errors.
Hello, I am stuck. I am supposed
to validate the input data type into txtBox before allowitn the program to continue but I keep getting too many errors.
Hi @Hekzdaddy-3952 ,
If you need further assistance, you can share your project on onedrive or GitHub, or write an answer to post your code.
Red needs to move to to where the other private variables are, blue needs to move outside of btnCalcluate and can only assume yellow belongs with blue. In the future post code and the image, this way if you had done that I could had made the changes.


Public Class Form1
Private Function ValidateInputFields() As Boolean
Public Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
'try to convert each of the input fields. Return false if
'any of the fields in invalid, and display a suitable error message.
If Not Decimal.TryParse(txtBoxLabor.Text, dectxtBoxLabor) Then
lblLabor.Text = "retail must be numeric"
Return False
End If
If Not Decimal.TryParse(txtBoxParts.Text, dectxtBoxParts) Then
lblParts.Text = "type in a number"
Return False
End If
Return True
End fucntions
End Sub
Still having an issue, I've attached a new image and partial code (full code exceeded 1000 character limit).
This was done in notepad, see if this resolve the issue.
Private Function ValidateInputFields() As Boolean
If Not Decimal.TryParse(txtBoxLabor.Text, dectxtBoxLabor) Then
lblLabor.Text = "retail must be numeric"
Return False
End If
If Not Decimal.TryParse(txtBoxParts.Text, dectxtBoxParts) Then
lblParts.Text = "type in a number"
Return False
End If
Return True
End Function
Public Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
If ValidateInputFields() Then
'
Else if
'
End If
End Sub
I would also encourage you to learn how to work with Git in Visual Studio. Knowing Git means you can use a link rather than post code here.
https://docs.microsoft.com/en-us/visualstudio/ide/git-with-visual-studio?view=vs-2019
5 people are following this question.