投稿日 | : 2003/08/18(Mon) 22:09 |
投稿者 | : たけちゃん |
Eメール | : |
URL | : |
タイトル | : 計算結果がなぜか0になる?? |
こんばんは、先日はありがとうございました。
この度、自分で試しにコーディングしたのですが、どうしても
計算結果が0になりますが、どうしてですか?
データ型宣言がおかしいのですか?
少し長いですが、下記にコーディングを書いておきます。
Private Sub Command1_Click()
Dim u As Double
u = s + t
Debug.Print u
End Sub
Private Sub Text1_Change()
If Len(Text1.Text) >= 3 Then
Text2.SetFocus
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
Dim s As Double
If KeyAscii = vbKeyReturn Then
KeyAscii = 0
s = Val(Text1.Text & "." & Text2.Text)
Debug.Print s
Text3.SetFocus
End If
End Sub
Private Sub Text3_Change()
If Len(Text3.Text) >= 2 Then
Text4.SetFocus
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
Dim t As Double
If KeyAscii = vbKeyReturn Then
KeyAscii = 0
t = Val(Text3.Text & "." & Text4.Text)
Debug.Print t
Command1.SetFocus
End If
End Sub