が動作していないことは、私のコードです:それはdblprevious
がdblcurrent
より大きい場合invalidinputを呼び出すためのものです が、それは私が知っている代わりに、負の出力を示しているその単純なことになったなぜ私のメッセージボックスがここに
Public Class Form1
'names the the class veriables
Dim dblCurrent As Double
Dim dblPervious As Double
Private Sub invalidinput()
Const Message As String = "check your input"
Const title As String = " Attention!"
Const buttons = MessageBoxButtons.OK
MessageBox.Show(Message, title, buttons)
End Sub
Private Sub Total()
Dim dblTotalP As Double
Dim dblTotalG As Double
Const dblPerGC As Double = 5.15
Const dbltMinC As Double = 19.69
'stores the veriables
Double.TryParse(txtCurrentreading.Text, dblCurrent)
Double.TryParse(txtPerivousreading.Text, dblPervious)
dblTotalG = dblCurrent - dblPervious
dblTotalP = dblTotalG/1000 * dblPerGC
If dblTotalP < dbltMinC Then
dblTotalP = dbltMinC
End If
'displays totals
lblTotalG.Text = dblTotalG
lblTotalP.Text = dblTotalP.ToString("C2")
End Sub
Private Sub bntExit_Click(sender As Object, e As EventArgs) Handles bntExit.Click
Me.Close()
End Sub
Private Sub txtCurrentreading_keypress(sender As Object, e As KeyPressEventArgs) Handles txtCurrentreading.KeyPress
'allows text box to accept only numbers and the back space key
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub txtPerivousreading_keypess(sender As Object, e As KeyPressEventArgs) Handles txtPerivousreading.KeyPress
'allows text box to accept only numbers and the back space key
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub bntCalculate_Click(sender As Object, e As EventArgs) Handles bntCalculate.Click
'determines which calculations to do
If dblCurrent >= dblPervious Then
Call Total()
ElseIf dblPervious < dblCurrent Then
Call invalidinput()
End If
End Sub
End Class
デバッガをMS Accessの一部として使用すると、ブレークポイントを設定してコードを1行ずつ進めることができます。 – nicomp
[mcve]を読んで、小さなプログラムをデバッグする際の一番下にリンクされている非常に役立つページを読んでください。多くの人々は、[mcve]を作成すると、問題を解決するのに役立つことがわかります。 – AdrianHHH
'Call'キーワードを使う必要はありません。それは余計です。 –