Public Class Form1
Private ope
As String =
Nothing
Private beforeIn
As String =
"C"
Private ans
As Long = 0
Private num
As Long = 0
Private Sub
Form1_Load(ByVal sender
As System.Object,
ByVal e
As System.EventArgs)
Handles MyBase.Load
'電卓ロード時に0が表示されるので、VFD256にも0を表示
'Ml(パラメータ)で指定することで48ドットで表示
Shell("d:\VFD256\VFD256DISP.EXE
/Ml ""0""")
End Sub
'数字ボタン1を押
した際の処理。同様に0~9までの数字ボタンを作ります。
Private Sub Btn1_Click(ByVal sender
As System.Object,
ByVal e
As System.EventArgs)
Handles Btn1.Click
If beforeIn >=
"0"
And beforeIn <=
"9"
Then
If LblAnser.Text.Length < 8
Then
LblAnser.Text &= "1"
'ボタン1が押され桁増加でLblAnser.Textに表示された内容をShell関数でVFD256に表示
Shell("d:\VFD256\VFD256DISP.EXE /Ml " & LblAnser.Text)
End If
Else
LblAnser.Text = "1"
'ボタン1が押されLblAnser.Textに表示された内容をShell関数でVFD256に表示
Shell("d:\VFD256\VFD256DISP.EXE /Ml " & LblAnser.Text)
End If
beforeIn = "1"
End Sub
'+ボタンを押した際の処理
Private Sub BtnPlus_Click(ByVal
sender
As System.Object,
ByVal e
As System.EventArgs)
Handles BtnPlus.Click
If beforeIn
>=
"0"
And beforeIn <=
"9"
Then
If
ope =
"C"
Then
ans =
CInt(LblAnser.Text)
Else
num =
CInt(LblAnser.Text)
ans = ans + num
LblAnser.Text = ans
End If
Else
Select Case
ope
Case
"C"
ans =
CInt(LblAnser.Text)
Case
"="
ans = ans + num
Case
"+"
num = ans
End Select
End If
beforeIn =
"+"
ope =
"+"
Shell("d:\VFD256\VFD256DISP.EXE
/Ml " & LblAnser.Text)
End Sub
'-ボタン
を押した際の処理
Private Sub BtnMinus_Click(ByVal
sender
As System.Object,
ByVal e
As System.EventArgs)
Handles BtnMinus.Click
If beforeIn >=
"0"
And beforeIn <=
"9"
Then
If
ope =
"C"
Then
ans = CInt(LblAnser.Text)
Else
num = CInt(LblAnser.Text)
ans = ans - num
LblAnser.Text = ans
End If
Else
Select Case
ope
Case
"C"
ans =
CInt(LblAnser.Text)
Case
"="
ans = ans - num
Case
"+",
"-"
num = ans
End Select
End If
beforeIn =
"-"
ope =
"-"
Shell("d:\VFD256\VFD256DISP.EXE
/Ml " & LblAnser.Text)
End Sub
'=ボタンを押した際の処理
Private Sub BtnEqual_Click(ByVal
sender As System.Object,
ByVal e
As System.EventArgs)
Handles BtnEqual.Click
If beforeIn >=
"0"
And
beforeIn <=
"9"
Then
num =
CInt(LblAnser.Text)
Shell("d:\VFD256\VFD256DISP.EXE
/Ml "
& LblAnser.Text)
End If
Select Case ope
Case
"+"
ans = ans + num
Shell("d:\VFD256\VFD256DISP.EXE
/Ml " &
LblAnser.Text)
Case
"-"
ans = ans - num
Shell("d:\VFD256\VFD256DISP.EXE
/Ml " & LblAnser.Text)
End Select
LblAnser.Text = ans
Shell("d:\VFD256\VFD256DISP.EXE
/Ml " & LblAnser.Text)
beforeIn =
"C"
End Sub
'クリアボタンを押した際の処理
Private Sub BtnClear_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles BtnClear.Click
ans = 0
num = 0
beforeIn =
"C"
ope =
"C"
LblAnser.Text =
"0"
'クリアボタンを押した時にVFD256の表示をクリアし、その後0を表示
Shell("d:\VFD256\VFD256DISP.EXE /CLS")
Shell("d:\VFD256\VFD256DISP.EXE /Ml
""0""")
End Sub
End Class |