Imports System.Runtime.InteropServices
Public Class Form1
Dim USBIF4CW_ver As Integer
Dim tmp As String
Dim tmp1 As String
Dim tmp2 As String
Dim buf As String
Dim tx_str As String
Dim Sleep_time As Integer
Dim nagasa(100) As Integer
Dim usbif4cwIsTxBusy_fp As Integer
Dim fp1 As Integer
Dim fp2 As Integer
Dim dat() As String
Private frm2 As New Form2
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
read_ini_sub()
Label6.Text = ""
Label7.Text = ""
lblLeft.Text = ""
lblDown.Text = ""
lblRight.Text = ""
'ファイル名を得る
'FileName = IO.Path.GetFileName("C:\Winnt\System32\User32.dll") 'User32.dll を返す。
'フォルダ名を得る
'FolderName = IO.Path.GetDirectoryName("C:\Winnt\System32\User32.dll") 'C:\Winnt\System32 を返す
'拡張子を除いたファイル名を取得
'FileName = IO.Path.GetFileNameWithoutExtension("C:\Winnt\System32\User32.dll") 'User32 を返す。
'拡張子だけを取得
'ExtName = IO.Path.GetExtension("C:\Winnt\System32\User32.dll") '.dll を返す。
End Sub
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
cmdF1.Text = F1_d
cmdF2.Text = F2_d
cmdF3.Text = F3_d
cmdF4.Text = F4_d
cmdF5.Text = F5_d
cmdF6.Text = F6_d
cmdF7.Text = F7_d
cmdF8.Text = F8_d
lblLeft.Text = Left_d
lblDown.Text = Down_d
lblRight.Text = Right_d
'set_wpm = 35
NumericUpDown1.Value = set_wpm
Call usbif4cwOpen(0)
Call usbif4cwSetWPM(0, set_wpm)
USBIF4CW_ver = usbif4cwGetVersion(0)
Label1.Text = "USBIF4CW ver = " & USBIF4CW_ver / 10
Me.KeyPreview = True
End Sub
Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
If e.KeyCode = Keys.F1 Then
TX_CW_sub(F1_m)
ElseIf e.KeyCode = Keys.F2 Then
TX_CW_sub(F2_m)
ElseIf e.KeyCode = Keys.F3 Then
TX_CW_sub(F3_m)
ElseIf e.KeyCode = Keys.F4 Then
TX_CW_sub(F4_m)
ElseIf e.KeyCode = Keys.F5 Then
TX_CW_sub(F5_m)
ElseIf e.KeyCode = Keys.F6 Then
TX_CW_sub(F6_m)
ElseIf e.KeyCode = Keys.F7 Then
TX_CW_sub(F7_m)
ElseIf e.KeyCode = Keys.F8 Then
TX_CW_sub(F8_m)
ElseIf e.KeyCode = Keys.Left Then
TX_CW_sub(Left_m)
ElseIf e.KeyCode = Keys.Down Then
TX_CW_sub(Down_m)
ElseIf e.KeyCode = Keys.Right Then
TX_CW_sub(Right_m)
End If
End Sub
Private Sub cmdF1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdF1.Click
TX_CW_sub(F1_m)
End Sub
Private Sub cmdF2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdF2.Click
TX_CW_sub(F2_m)
End Sub
Private Sub cmdF3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdF3.Click
TX_CW_sub(F3_m)
End Sub
Private Sub cmdF4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdF4.Click
TX_CW_sub(F4_m)
End Sub
Private Sub cmdF5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdF5.Click
TX_CW_sub(F5_m)
End Sub
Private Sub cmdF6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdF6.Click
TX_CW_sub(F6_m)
End Sub
Private Sub cmdF7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdF7.Click
TX_CW_sub(F7_m)
End Sub
Private Sub cmdF8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdF8.Click
TX_CW_sub(F8_m)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'test TX
Call usbif4cwSetWPM(0, set_wpm)
tmp = "JA2BQX QSL 5NN MY NAME IS NOBU NOBU QTH FUJIEDA BK"
'tmp = "JA2BQX/3 QSL? BK"
tmp = Replace(tmp, "$M", MyCall)
tmp2 = ""
dat = tmp.Split(" ")
Timer1.Interval = 100
Timer1.Enabled = True
fp1 = 0
fp2 = Microsoft.VisualBasic.UBound(dat)
End Sub
Private Sub usbif4cwPutChar_sub()
If fp1 < fp2 Then
tmp1 = dat(fp1) & " "
Else
tmp1 = dat(fp1)
End If
For j As Integer = 1 To Microsoft.VisualBasic.Len(tmp1)
buf = Microsoft.VisualBasic.Strings.Mid(tmp1, j, 1)
Call usbif4cwPutChar(0, Asc(buf))
tmp2 = tmp2 & buf
Label7.Text = tmp2
Next j
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
usbif4cwIsTxBusy_fp = usbif4cwIsTxBusy(0)
Label6.Text = "待機文字数 : " & usbif4cwIsTxBusy_fp
If usbif4cwIsTxBusy_fp = 0 Then
If fp1 < fp2 + 1 Then
usbif4cwPutChar_sub()
fp1 = fp1 + 1
Else
Timer1.Enabled = False
End If
End If
End Sub
Private Sub TX_CW_sub(ByVal tx_str)
tmp2 = ""
Call usbif4cwSetWPM(0, set_wpm)
tx_str = Replace(tx_str, "$M", MyCall)
dat = tx_str.Split(" ")
Timer1.Interval = 100
Timer1.Enabled = True
fp1 = 0
fp2 = Microsoft.VisualBasic.UBound(dat)
End Sub
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
set_wpm = NumericUpDown1.Value
End Sub
Private Sub 設定ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 設定ToolStripMenuItem.Click
Me.Hide()
Form2.Show()
End Sub
Private Sub 終了ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 終了ToolStripMenuItem.Click
write_ini_sub()
Call usbif4cwClose(0)
Application.Exit()
End Sub
End Class