ok guys,

I've got an issue where a computation is just not working but I've used the same set up in other programs and don't truly understand the deal with this one. at the beginning of the below if (the whole program lower) statement i find if a number is valid and when it is a perform a computation but the computation is not coming out. can anyone expose the error of my ways?

If Val(Me.xCurrentTextBox.Text) <= Val(Me.xPreviousTextBox.Text) Then
            MessageBox.Show("Current reading must be higher than the previous reading.")
        Else
[B]            Me.xGallonsUsedLabel.Text = CStr(Val(Me.xCurrentTextBox.Text) - Val(Me.xPreviousTextBox.Text))
            Me.xTotalChargeLabel.Text = CStr(Val(Me.xGallonsUsedLabel.Text) * 0.00175)[/B]
        End If
' Project name:     Allenton Project

Option Explicit On
Option Strict On

Public Class MainForm

    Private Sub xExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xExitButton.Click
        Me.Close()
    End Sub

    Private Sub CancelKeys(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _
        Handles xCurrentTextBox.KeyPress, _
        xPreviousTextBox.KeyPress

        'allows numbewrs, the backspace key & the period

        If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
            AndAlso e.KeyChar <> ControlChars.Back Then
            'cancel the key
            e.Handled = True
        End If
    End Sub


    Private Sub ClearPayment(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles xGallonsUsedLabel.TextChanged, _
    xTotalChargeLabel.TextChanged
        ' clears the monthly payment when a new number is entered

        Me.xGallonsUsedLabel.Text = String.Empty
        Me.xTotalChargeLabel.Text = String.Empty

    End Sub

    Private Sub xCalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xCalcButton.Click

        If Val(Me.xCurrentTextBox.Text) <= Val(Me.xPreviousTextBox.Text) Then
            MessageBox.Show("Current reading must be higher than the previous reading.")
        Else
[B]            Me.xGallonsUsedLabel.Text = CStr(Val(Me.xCurrentTextBox.Text) - Val(Me.xPreviousTextBox.Text))
            Me.xTotalChargeLabel.Text = CStr(Val(Me.xGallonsUsedLabel.Text) * 0.00175)[/B]
        End If

    End Sub
End Class

there are none error, your code its fine. what the error that you found in it?? the bold code its right.

The code syntax is correct . it seems there is some logic error in your code. Run the code using brake points and check.

Run the code using brake points and check.

what are brake points?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.