Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
2SerialPorts_RealTime_dataReceiving ,10msec Sampling will need Hi-Peformace PC will recommend
'Seril Port Recieve Sample Program
'Form1 Object must create ,button1,2 & textbox 1,2 
Imports System.Drawing
Imports System.IO.Ports
Public Class Form1
Dim ReceivedData1 As String = " " '受信データ用変数を宣言します
Dim ReceivedData2 As String = " " '受信データ用変数を宣言します
Dim ReceivedData3 As String = " "
Dim header As String
Dim rdata1 As String = ""
Dim rdata2 As String = ""
Dim rdata3 As String = ""
Dim Aflag As Integer = 0
Dim Bflag As Integer = 0
Dim sdnum As Integer
Dim dcount As Integer = 0
Dim dummy As String
Private com1_None As Integer
Private com2_None As Integer
'==========LinearMode Parameteres==============
Public cp1X As Integer(,)
Public cp1Y As Integer(,)
Public cp2X As Integer(,)
Public cp2Y As Integer(,)
Public cp3X As Integer(,)
Public cp3Y As Integer(,)
'===========Controls ==============
Dim Ch_sel(16) As Integer
Dim shokaiN As Integer
Dim Chsuu As Integer
'=========Receive Stop===========
Public rFlag As Integer = 1
Public rcFlag As Integer = 0
'=======file===============
Public fname As String = ""
Public file As System.IO.StreamWriter
Public fsdata As String
'======PictureBoxSize========
Const yh = 240
Const xw = 600
Private onetime As Integer = 1
Delegate Sub DataDelegate(ByVal sdata As String)
'=========Available Parameters in thie Class=================
Private dStr(100) As String
Private dataAry(60000, 16) As Long
Private dataNo As Long
Dim stm As Integer = 0
'---------Plotting parameters--------------
Private rate() As Double
Private Mag As Double
Private midvalue() As Double
Private dstep As Double 'x軸ドット単位 dot/dataNo
Private dvalue As Double = 1 'Y軸ドット単位 dot/mV 10mvで1ドット
'-----------------------------------------
Private Mave() As Double
Private sw As New System.Diagnostics.Stopwatch()
Private sw1 As New System.Diagnostics.Stopwatch()
Private tp As TimeSpan
Private tr As TimeSpan
Private timestamp As Integer
Private stime As Integer 'plot start sampling time
Private etime As Integer 'plot end sampling time
Private totalsec As Double
Private startFlag As Integer = 0
Private px As Integer
Private py As Integer
Private px_1 As Integer
Private py_1 As Integer '1個前のY座標
'===============================MAIN===========================================================================================================================
'=============================PRINT DATA=======================================================================================================================
'==============================================================================================================================================================
Private Sub PrintData(ByVal sdata As String)
''*********************Object Array set****************************************************************************
Dim CH_checkbox() As CheckBox
CH_checkbox = {Me.CheckBox1, Me.CheckBox2, Me.CheckBox3, Me.CheckBox4, Me.CheckBox5, Me.CheckBox6, Me.CheckBox7, Me.CheckBox13, Me.CheckBox14, Me.CheckBox15, Me.CheckBox16, Me.CheckBox17, Me.CheckBox18, Me.CheckBox19, Me.CheckBox20, Me.CheckBox21}
Dim dataTextBox() As TextBox
dataTextBox = {Me.TextBox4, Me.TextBox5, Me.TextBox6, Me.TextBox7, Me.TextBox8, Me.TextBox9, Me.TextBox10, Me.TextBox29, Me.TextBox31, Me.TextBox33, Me.TextBox35, Me.TextBox37, Me.TextBox39, Me.TextBox41, Me.TextBox43, Me.TextBox45}
Dim adjustComboBox() As ComboBox
adjustComboBox = {Me.ComboBox1, Me.ComboBox2, Me.ComboBox3, Me.ComboBox4, Me.ComboBox5, Me.ComboBox6, Me.ComboBox7, Me.ComboBox12, Me.ComboBox13, Me.ComboBox14, Me.ComboBox15, Me.ComboBox16, Me.ComboBox17, Me.ComboBox18, Me.ComboBox19, Me.ComboBox20}
Dim midTextBox() As TextBox
midTextBox = {Me.TextBox13, Me.TextBox14, Me.TextBox15, Me.TextBox16, Me.TextBox17, Me.TextBox18, Me.TextBox19, Me.TextBox28, Me.TextBox30, Me.TextBox32, Me.TextBox34, Me.TextBox36, Me.TextBox38, Me.TextBox40, Me.TextBox42, Me.TextBox44}
'******************************************************************************************************************
'===Start StopWatch====
If dcount = 0 Then
sw.Start()
End If
dcount += 1
'Debug.Print(dcount)
'========First CSV File Declaration======================
If CheckBox8.Checked = True And fname = "" Then
fname = Format(Now, "yyyyMMdd_HHmmss")
fname = "C:\vb_LOG\" & fname & ".csv"
TextBox21.Text = fname
'---MS Example------------------------------
'Dim file As System.IO.StreamWriter
'file = My.Computer.FileSystem.OpenTextFileWriter("c:\test.txt", True)
'file.WriteLine("Here is the first string.")
'file.Close()
'------------------------------------------
Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding(“Shift_JIS”)
file = My.Computer.FileSystem.OpenTextFileWriter(fname, False, enc)
End If
' Debug.Print("sdata=" & sdata)
'=======sdata File writing====================
If System.IO.File.Exists(fname) And CheckBox8.Checked = True Then
fsdata = sdata.Substring(0, sdata.Length - 2) + Chr(13) + Chr(10)
'fsdata = sdata.Substring(0, sdata.Length - 2) + ",80data_time=" + CStr(stm) + Chr(13) + Chr(10)
file.Write(fsdata)
Label7.Text = "Logging"
End If
''=====Port1 A, +Port2 B,合体==============================
If CheckBox22.Checked = True Then
header = sdata.Substring(0, 3)
Debug.Print(header)
sdnum = sdata.Length
Debug.Print(sdnum)
If header = "A,1" And sdnum > 5 Then
rdata1 = sdata.Substring(2, sdnum - 2)
Aflag = 1
'Debug.Print("rdata1=")
'Debug.Print(rdata1)
End If
If header = "B,1" And sdnum > 5 Then
rdata2 = sdata.Substring(2, sdnum - 2)
Bflag = 1
'Debug.Print("rdata2=")
'Debug.Print(rdata2)
'Debug.Print("--------------")
End If
If Aflag = 1 And Bflag = 1 Then
rdata3 = rdata1 + "," + rdata2
'Debug.Print("rdata3=")
'Debug.Print(rdata3)
'TextBox48.Text = rdata3
End If
End If
'=================================================================
'=============ListBox=====================
If dcount Mod 50 = 0 Then
sw.Stop()
stm = sw.ElapsedMilliseconds
sw.Start()
TextBox46.Text = dcount
TextBox47.Text = stm
'CheckBox11.Checked = False
ListBox1.Items.Add("time=" + CStr(stm))
End If
If CheckBox11.Checked = True And CheckBox22.Checked = False Then
ListBox1.Visible = True
ListBox1.Items.Add(sdata)
End If
If CheckBox11.Checked = True And CheckBox22.Checked = True Then
ListBox1.Visible = True
ListBox1.Items.Add(rdata3)
End If
If CheckBox11.Checked = False Then
ListBox1.Visible = False
End If
'=======================================
Dim delimiter As String = ","
Dim i, j, k As Integer
'Dim stdata As String
Dim dStrAry(100) As String
'============================SPLITTING============================
'==================================================================
If rdata3.Length > 6 And CheckBox12.Checked = True Then
dStr = Split(rdata3, delimiter, -1, CompareMethod.Text)
Chsuu = dStr.Length
TextBox3.Text = Chsuu
End If
'If sdata.Length > 5 Then
' '=======================TextBox $ LIST BOX=======================================
' 'Console.WriteLine("Text:{0}", ListBox1.Text)
' If CheckBox11.Checked = True Then
' ListBox1.Visible = True
' ListBox1.Items.Add(sdata) ' & ",index1=," & CStr(index1))
' 'ListBox1.Items.Add("COM6:" & dStr(0) & "," & dStr(7) & "COM11:" & dStr(8) & "," & dStr(10) & "VBtime=" & CStr(index1))
' 'TextBox12.Text = sdata & ",index1=," & CStr(index1)
' TextBox12.Text = stdata '& CStr(index1)
' End If
' 'TextBox12.Text = "COM6:" & dStr(0) & "," & dStr(7) & "COM11:" & dStr(8) & "," & dStr(10) & "VBtime=" & CStr(index1)
' If CheckBox11.Checked = False Then
' ListBox1.Visible = False
' End If
'-------------初回だけCHチェックとチェックボックス-------------------------
'If shokaiN = 1 Then
' CheckCH()
' Ch_sel = CheckBR() 'CheckBox Checked array 1=ON 0=OFF
' shokaiN = 0
' Debug.Print("ShokaiN=1 CH Check Done")
'End If
'==========================Data write to 16 TextBox 16 CheckBox 20回に1回更新 ============================================
'If dataNo Mod 10 = 0 Then
' For k = 0 To 15
' If Ch_sel(k) Then
' dataTextBox(k).Text = dStr(k)
' End If
' Next k
'End If
'======同期ズレ表示======================
'If dataNo Mod 200 = 0 Then
' If SerialPort2.IsOpen = True And dStr.Length > 7 Then
' TextBox46.Text = dStr(0)
' TextBox47.Text = CInt(dStr(0)) - CInt(dStr(8))
' End If
'End If
'End If
'---------------------------------dStr to dataAry--------------------------------------------------------------------------
'Debug.Print("dStr.length=" & CStr(dStr.Length) & "sdata.Length=" & CStr(sdata.Length))
If sdata.Length < 90 And sdata.Length > 6 And dStr.Length > 1 And CheckBox12.Checked Then 'dStr.Length = 7 And sdata.Length < 37
Try
dataNo = (dataNo + 1) Mod 3000
TextBox2.Text = dataNo
'Debug.Print("SPLITed TextBox Printing")
For i = 0 To dStr.Length - 1
If dStr(i) <> "" Then
TextBox1.Text = dStr(i)
dataAry(dataNo, i) = CInt(dStr(i))
End If
Next
If startFlag = 1 Then
'=================PLOT SUBへ=================
plotC(dataNo, 0, 0, 0) 'plotC(x,y,colorN)
'plotC(dataNo, dataAry(dataNo, i), dataAry(dataNo - 1, i), i) 'plotC(x,y,colorN)
'Debug.Print("dataAry()=" & CStr(dataAry(dataNo, i)) & "i=" & CStr(i))
'End If
'===========================================
End If
'Debug.Print("dataAry(" & CStr(dataNo) & "," & CStr(i) & ")=" & CStr(dataAry(dataNo, i)))
Catch ex As Exception
Console.WriteLine(ex.Message)
Console.WriteLine("Error in dstr=>dataAry")
End Try
End If
'End If
End Sub
'==========================================MAIN BOTTOM========================================================================================================
'=============================================================================================================================================================
'=============================================================================================================================================================
'*************************SerialPort Open Close REceive***************************************************************
'===================================================================================================================
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
SerialPort1.PortName = ComboBox10.SelectedItem 'TextBox1.Text 'オープンするポート名を格納
SerialPort2.PortName = ComboBox11.SelectedItem
If SerialPort1.PortName <> "None" Then
SerialPort1.Open() 'ポートオープン
Label2.Text = "Port1_OPENED"
com1_None = 0
SerialPort1.DiscardInBuffer()
End If
If SerialPort1.PortName = "None" Then
com1_None = 1
End If
If SerialPort2.PortName <> "None" Then
SerialPort2.Open() 'ポートオープン
Label22.Text = "Port2_OPENED"
com2_None = 0
SerialPort2.DiscardInBuffer()
End If
If SerialPort2.PortName = "None" Then
com2_None = 1
End If
'Received CheckBox ON
CheckBox9.Checked = True
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim k As Integer
If System.IO.File.Exists(fname) Then
file.Close()
Label7.Text = "FileClosed"
fname = ""
TextBox21.Text = fname
End If
If SerialPort1.IsOpen = True Then 'ポートオープン済み
SerialPort1.Close() 'ポートクローズ
Label2.Text = "Port1_CLOSED"
End If
If SerialPort2.IsOpen = True Then 'ポートオープン済み
SerialPort2.Close() 'ポートクローズ
Label22.Text = "Port2_CLOSED"
End If
End Sub
Private Sub PrintData1(ByVal sdata As String)
ListBox1.Items.Add(sdata)
End Sub
'***************************************************************************************************************************
'******************************DataReceiving********************************************************************************
'***************************************************************************************************************************
Private Sub SerialPort1_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
If CheckBox9.Checked = True And com1_None = 0 Then
Try
'SerialPort1.DiscardInBuffer()
ReceivedData1 = "A," + SerialPort1.ReadLine 'データを受信します
'If SerialPort2.IsOpen = True Then
' 'SerialPort2.DiscardInBuffer()
' ReceivedData2 = SerialPort2.ReadLine
' ReceivedData3 = ReceivedData1 & "," & ReceivedData2
'Else
'ReceivedData3 = ReceivedData1
'End If
'Invokeメソッドにより実行されるメソッドへのデリゲートの宣言を行い、受信データを表示します
Dim adre As New DataDelegate(AddressOf PrintData)
Me.Invoke(adre, ReceivedData1)
Catch ex As Exception
ReceivedData1 = ex.Message '例外処理を行います
'Console.WriteLine("Error in DataReceived1")
End Try
SerialPort1.DiscardInBuffer()
End If
End Sub
Private Sub SerialPort2_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
If CheckBox9.Checked = True And com2_None = 0 Then
Try
'SerialPort2.DiscardInBuffer()
ReceivedData2 = "B," + SerialPort2.ReadLine 'データを受信します
Dim adre As New DataDelegate(AddressOf PrintData)
Me.Invoke(adre, ReceivedData2)
Catch ex As Exception
ReceivedData2 = ex.Message '例外処理を行います
'Console.WriteLine("Error in DataReceived2")
End Try
'Invokeメソッドにより実行されるメソッドへのデリゲートの宣言を行い、受信データを表示します
SerialPort2.DiscardInBuffer()
End If
End Sub
'*****************************************************************************************************************************
'*****************************************************************************************************************************
'*****************************************************************************************************************************
'=================================================================================================================
'===================================SerialPort Setting End==================================================================
'=================================================================================================================
'===============Plotting Start Button=======================
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If startFlag = 0 Then
startFlag = 1
Label20.Text = "--Plotting--"
End If
End Sub
'===============Plotting Stop===================================
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
If startFlag = 1 Then
startFlag = 0
Label20.Text = "--PlotStopped--"
End If
End Sub
'**************************************************************************************************************************************************
'================================描画メソッドPlotc()===================================================
'===========-PLOT パラメータの定義 計算方式===================================================
'===========ゼロレベルでデフォルト平均値(1650mV)をとってCenteringを実施してY軸中心にそろえる===============
'===========負荷をいれながらrate値(ドット/mV)を手動で変えて最適値にセット========================
'==========================================================================================
Sub plotC(ByVal dataNo As Integer, ByVal value As Integer, ByVal value_1 As Integer, ByVal colorN As Integer)
If PictureBox1.Image Is Nothing Then '初回だけBITMAPを定義する Picture1.imageという名称をつかうこと
PictureBox1.Image = New Bitmap(720, 240)
End If
Dim g As Graphics = Graphics.FromImage(PictureBox1.Image)
Ch_sel = CheckBR() 'CheckBox Checked array 1=ON 0=OFF
'==============Text Box Value Reading===================================
Dim rate(16) As Double
Dim midvalue(16) As Double
rate = RateCR() ' rate(0-16)はdot/mV
midvalue = AvTR() 'midvalue(0-16)はゼロレベル値
'==============TrackBar value Read==============
Dim TBvalue As Integer
Dim TBposition As Integer
TBvalue = TrackBar1.Value
TBposition = CInt(TBvalue / 100 * yh)
TextBox20.Text = CStr(TBvalue)
'*************************************************************************************
'**************************************************************************************
'=========================================================================
'=================Plot Oresen Graph=========================================
'=========================================================================
'------------Pen COLORS------------
Dim p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16 As New Pen(Color.Black)
Dim p As New Pen(Color.Black)
'Dim p(16) As Pen
Dim b As Brush
b = Brushes.Black
p1.Width = 0.1
p2.Width = 0.1
p3.Width = 0.1
p4.Width = 0.1
p5.Width = 0.1
p7.Width = 0.1
p8.Width = 0.1
p9.Width = 0.1
p10.Width = 0.1
p11.Width = 0.1
p12.Width = 0.1
p13.Width = 0.1
p14.Width = 0.1
p15.Width = 0.1
p16.Width = 0.1
p1 = Pens.Red
p2 = Pens.Blue
p3 = Pens.Green
p4 = Pens.Magenta
p5 = Pens.Orange
p6 = Pens.LemonChiffon
p7 = Pens.Lime
p8 = Pens.MediumSpringGreen
p9 = Pens.DeepPink
p10 = Pens.Crimson
p11 = Pens.SeaGreen
p12 = Pens.GreenYellow
p13 = Pens.Orchid
p14 = Pens.Maroon
p15 = Pens.DarkSlateBlue
p16 = Pens.DarkViolet
'=============PLOT パラメータ準備==============
Dim xscale As Integer = 2
'--Y軸
'-------------ドット変換値設定-------
dstep = 1 'X軸基本
Mag = CDbl(ComboBox8.SelectedItem) 'X軸倍率 0.01-0.5 1-10 dot/dataNo
'===========================Drawing=================================================================
If CheckBox10.Checked = False Then '*********False=Oresen View Mode /True=LenearViewMode
'===================スクロール クリア&時間測定========================================
' Debug.Print("dataNo=" & CStr(dataNo) & "cstr(600/Mag)=" & CStr(600 / Mag))
If dataNo Mod CInt(600 / Mag) = 0 Then '1画面終了したらimageクリア
tp = sw.Elapsed
totalsec = tp.TotalSeconds
' Debug.Print("tp.sec=" & totalsec)
sw.Stop()
If totalsec > 0.6 Then
TextBox11.Text = CStr(totalsec)
End If
sw.Reset()
sw.Start()
'Debug.Print("MOD 300:dataNo=" & CStr(dataNo))
SerialPort1.DiscardInBuffer()
PictureBox1.Image = Nothing '1スクロール毎に画面クリア
Else
'====================折れ線PLOT==============================================
'Debug.Print("dataNo=" & CStr(dataNo) & "value=" & CStr(value) & "midvalue=" & CStr(midvalue(0)) & "px=" & CStr(px) & "py=" & CStr(py))
'******************Plot Unit 1ch******************************
If Ch_sel(0) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(0) * (dataAry(dataNo, 0) - midvalue(0))) + TBposition)
'Debug.Print("------1ch_py:dataAry=" & CStr(dataAry(dataNo, 0)) & "midvalue=" & CStr(midvalue(0)))
py_1 = yh - (Int(rate(0) * (dataAry(dataNo - 1, 0) - midvalue(0))) + TBposition)
'Debug.Print("1ch_py_1:dataAry=" & CStr(dataAry(dataNo, 0)) & "midvalue=" & CStr(midvalue(0)))
g.DrawLine(p1, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
'Debug.Print("------1ch:px_1=" & CStr(px_1) & "px=" & CStr(px) & "py_1=" & CStr(py_1) & "py=" & CStr(py))
'g.FillEllipse(b, px, py, 5, 5) ' 点プロット この位置で動作OK
End If
'**********************************************************
'******************Plot Unit2ch******************************
If Ch_sel(1) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(1) * (dataAry(dataNo, 1) - midvalue(1))) + TBposition)
'Debug.Print("=======2ch_py:dataAry=" & CStr(dataAry(dataNo, 0)) & "midvalue=" & CStr(midvalue(1)))
py_1 = yh - (Int(rate(1) * (dataAry(dataNo - 1, 1) - midvalue(1))) + TBposition)
'Debug.Print("2ch_py_1:dataAry=" & CStr(dataAry(dataNo, 0)) & "midvalue=" & CStr(midvalue(1)))
g.DrawLine(p2, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
'Debug.Print("=====2ch:px_1=" & CStr(px_1) & "px=" & CStr(px) & "py_1=" & CStr(py_1) & "py=" & CStr(py))
End If
'**********************************************************
'******************Plot Unit3ch******************************
If Ch_sel(2) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(2) * (dataAry(dataNo, 2) - midvalue(2))) + TBposition)
py_1 = yh - (Int(rate(2) * (dataAry(dataNo - 1, 2) - midvalue(2))) + TBposition)
g.DrawLine(p3, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'******************Plot Unit4ch******************************
If Ch_sel(3) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(3) * (dataAry(dataNo, 3) - midvalue(3))) + TBposition)
py_1 = yh - (Int(rate(3) * (dataAry(dataNo - 1, 3) - midvalue(3))) + TBposition)
g.DrawLine(p4, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'******************Plot Unit5ch******************************
If Ch_sel(4) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(4) * (dataAry(dataNo, 4) - midvalue(4))) + TBposition)
py_1 = yh - (Int(rate(4) * (dataAry(dataNo - 1, 4) - midvalue(4))) + TBposition)
g.DrawLine(p5, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'******************Plot Unit6ch******************************
If Ch_sel(5) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(5) * (dataAry(dataNo, 5) - midvalue(5))) + TBposition)
py_1 = yh - (Int(rate(5) * (dataAry(dataNo - 1, 5) - midvalue(5))) + TBposition)
g.DrawLine(p6, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'******************Plot Unit7ch******************************
If Ch_sel(6) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(6) * (dataAry(dataNo, 6) - midvalue(6))) + TBposition)
py_1 = yh - (Int(rate(6) * (dataAry(dataNo - 1, 6) - midvalue(6))) + TBposition)
g.DrawLine(p7, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'******************Plot Unit8ch******************************
If Ch_sel(7) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(7) * (dataAry(dataNo, 7) - midvalue(7))) + TBposition)
py_1 = yh - (Int(rate(7) * (dataAry(dataNo - 1, 7) - midvalue(7))) + TBposition)
g.DrawLine(p8, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'******************Plot Unit9ch******************************
If Ch_sel(8) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(8) * (dataAry(dataNo, 8) - midvalue(8))) + TBposition)
py_1 = yh - (Int(rate(8) * (dataAry(dataNo - 1, 8) - midvalue(8))) + TBposition)
g.DrawLine(p9, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'******************Plot Unit10ch******************************
If Ch_sel(9) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(9) * (dataAry(dataNo, 9) - midvalue(9))) + TBposition)
py_1 = yh - (Int(rate(9) * (dataAry(dataNo - 1, 9) - midvalue(9))) + TBposition)
g.DrawLine(p10, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'******************Plot Unit11ch******************************
If Ch_sel(10) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(10) * (dataAry(dataNo, 10) - midvalue(10))) + TBposition)
py_1 = yh - (Int(rate(10) * (dataAry(dataNo - 1, 10) - midvalue(10))) + TBposition)
g.DrawLine(p11, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'******************Plot Unit12ch******************************
If Ch_sel(11) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(11) * (dataAry(dataNo, 11) - midvalue(11))) + TBposition)
py_1 = yh - (Int(rate(11) * (dataAry(dataNo - 1, 11) - midvalue(11))) + TBposition)
g.DrawLine(p12, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'******************Plot Unit13ch******************************
If Ch_sel(12) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(12) * (dataAry(dataNo, 12) - midvalue(12))) + TBposition)
py_1 = yh - (Int(rate(12) * (dataAry(dataNo - 1, 12) - midvalue(12))) + TBposition)
g.DrawLine(p13, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'******************Plot Unit14ch******************************
If Ch_sel(13) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(13) * (dataAry(dataNo, 13) - midvalue(13))) + TBposition)
py_1 = yh - (Int(rate(13) * (dataAry(dataNo - 1, 13) - midvalue(13))) + TBposition)
g.DrawLine(p14, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'******************Plot Unit15ch******************************
If Ch_sel(14) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(14) * (dataAry(dataNo, 14) - midvalue(14))) + TBposition)
py_1 = yh - (Int(rate(14) * (dataAry(dataNo - 1, 14) - midvalue(14))) + TBposition)
g.DrawLine(p15, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'******************Plot Unit16ch******************************
If Ch_sel(15) = 1 Then
px = Int((dstep * dataNo Mod CInt(600 / Mag)) * Mag)
px_1 = Int((dstep * (dataNo - 1) Mod CInt(600 / Mag)) * Mag)
py = yh - (Int(rate(15) * (dataAry(dataNo, 15) - midvalue(15))) + TBposition)
py_1 = yh - (Int(rate(15) * (dataAry(dataNo - 1, 15) - midvalue(15))) + TBposition)
g.DrawLine(p16, CSng(px_1), CSng(py_1), CSng(px), CSng(py))
End If
'**********************************************************
'Debug.Print("px_1=" & CStr(px_1) & "px=" & CStr(px) & "py_1=" & CStr(py_1) & "py=1" & CStr(py))
End If
g.Dispose()
'b.Dispose()
PictureBox1.Invalidate()
End If 'Oresen Graph End
'*************************************************************************************************************
'*************************Linear View Mode********************************************************************
'***************************720x240***************************************************************************
Dim x1ch, y1ch, x2ch, y2ch, x3ch, y3ch As Integer
ReDim cp1X(600000, 16)
ReDim cp1Y(600000, 16)
ReDim cp2X(600000, 16)
ReDim cp2Y(600000, 16)
ReDim cp3X(600000, 16)
ReDim cp3Y(600000, 16)
'Dim b As Brush
b = Brushes.Black
If CheckBox10.Checked = True Then
Debug.Print("Linear Mode In")
'----=WAKU---------------------
g.DrawRectangle(Pens.Black, 0, 0, 239, 239)
g.DrawRectangle(Pens.Black, 241, 0, 479, 239)
g.DrawRectangle(Pens.Black, 480, 0, 719, 239)
'-------Ellipse Color----------------
Select Case ComboBox9.SelectedIndex
Case 0
b = Brushes.Red
Case 1
b = Brushes.Blue
Case 2
b = Brushes.Green
Case 3
b = Brushes.Magenta
Case 4
b = Brushes.Orange
Case 5
b = Brushes.Black
End Select
'--Waku1-------------------------
If TextBox22.Text <> "" And TextBox23.Text <> "" Then
x1ch = CInt(TextBox22.Text) - 1 'array indexNo
y1ch = CInt(TextBox23.Text) - 1
cp1X(dataNo, x1ch) = yh - (Int(rate(x1ch) * (dataAry(dataNo, x1ch) - midvalue(x1ch))) + TBposition)
cp1Y(dataNo, y1ch) = yh - (Int(rate(y1ch) * (dataAry(dataNo, y1ch) - midvalue(y1ch))) + TBposition)
px = cp1X(dataNo, x1ch)
py = cp1Y(dataNo, y1ch)
g.FillEllipse(b, px, py, 3, 3) ' 点プロット
End If
'---Waku2----------------------------
If TextBox24.Text <> "" And TextBox25.Text <> "" Then
Dim xoff As Integer = 240
x2ch = CInt(TextBox24.Text) - 1 'array indexNo
y2ch = CInt(TextBox25.Text) - 1
cp2X(dataNo, x2ch) = yh - (Int(rate(x2ch) * (dataAry(dataNo, x2ch) - midvalue(x2ch))) + TBposition)
cp2Y(dataNo, y2ch) = yh - (Int(rate(y2ch) * (dataAry(dataNo, y2ch) - midvalue(y2ch))) + TBposition)
px = cp2X(dataNo, x2ch) + xoff
py = cp2Y(dataNo, y2ch)
g.FillEllipse(b, px, py, 3, 3) ' 点プロット
End If
'---Waku3----------------------------
If TextBox26.Text <> "" And TextBox27.Text <> "" Then
Dim xoff As Integer = 480
x3ch = CInt(TextBox26.Text) - 1 'array indexNo
y3ch = CInt(TextBox27.Text) - 1
cp3X(dataNo, x3ch) = yh - (Int(rate(x3ch) * (dataAry(dataNo, x3ch) - midvalue(x3ch))) + TBposition)
cp3Y(dataNo, y3ch) = yh - (Int(rate(y3ch) * (dataAry(dataNo, y3ch) - midvalue(y3ch))) + TBposition)
px = cp3X(dataNo, x3ch) + xoff
py = cp3Y(dataNo, y3ch)
g.FillEllipse(b, px, py, 3, 3) ' 点プロット
End If
g.Dispose()
PictureBox1.Invalidate()
End If
End Sub
'********************************************************************************************************************************************************
'=====================================================================================================================
'===============================================Form Load Init==================================================
'=====================================================================================================================
'========================================================================================
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
''*********************Object Array set****************************************************************************
Dim CH_checkbox() As CheckBox
CH_checkbox = {Me.CheckBox1, Me.CheckBox2, Me.CheckBox3, Me.CheckBox4, Me.CheckBox5, Me.CheckBox6, Me.CheckBox7, Me.CheckBox13, Me.CheckBox14, Me.CheckBox15, Me.CheckBox16, Me.CheckBox17, Me.CheckBox18, Me.CheckBox19, Me.CheckBox20, Me.CheckBox21}
Dim dataTextBox() As TextBox
dataTextBox = {Me.TextBox4, Me.TextBox5, Me.TextBox6, Me.TextBox7, Me.TextBox8, Me.TextBox9, Me.TextBox10, Me.TextBox29, Me.TextBox31, Me.TextBox33, Me.TextBox35, Me.TextBox37, Me.TextBox39, Me.TextBox41, Me.TextBox43, Me.TextBox45}
Dim adjustComboBox() As ComboBox
adjustComboBox = {Me.ComboBox1, Me.ComboBox2, Me.ComboBox3, Me.ComboBox4, Me.ComboBox5, Me.ComboBox6, Me.ComboBox7, Me.ComboBox12, Me.ComboBox13, Me.ComboBox14, Me.ComboBox15, Me.ComboBox16, Me.ComboBox17, Me.ComboBox18, Me.ComboBox19, Me.ComboBox20}
Dim midTextBox() As TextBox
midTextBox = {Me.TextBox13, Me.TextBox14, Me.TextBox15, Me.TextBox16, Me.TextBox17, Me.TextBox18, Me.TextBox19, Me.TextBox28, Me.TextBox30, Me.TextBox32, Me.TextBox34, Me.TextBox36, Me.TextBox38, Me.TextBox40, Me.TextBox42, Me.TextBox44}
'******************************************************************************************************************
'Dim arry() As Integer = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}
'================COMBOBOX Def=============================
ComboBox1.Items.Clear()
Dim n As Integer
shokaiN = 1
For i = 0 To 15
adjustComboBox(i).Items.Add("0.1") '0.1mv/yh_DOT
adjustComboBox(i).Items.Add("0.2")
adjustComboBox(i).Items.Add("0.5")
adjustComboBox(i).Items.Add("1") '1mv?yh?DOT
adjustComboBox(i).Items.Add("2")
adjustComboBox(i).Items.Add("5")
adjustComboBox(i).Items.Add("10") '10mV/yh_DOT
adjustComboBox(i).Items.Add("20")
adjustComboBox(i).Items.Add("50") '50mV?yh_DOT
'adjustComboBox(i).Items.Add("90")
'adjustComboBox(i).Items.Add("100")
Next
For i = 0 To 15
adjustComboBox(i).SelectedIndex = 3
midTextBox(i).Text = CStr(1550)
CH_checkbox(i).Checked = True
Next i
'==================COMBOBOX8 X_Mag scale=================================
'===============1,2,3,4,5,6,10,12==================================
ComboBox8.Items.Add("0.01")
ComboBox8.Items.Add("0.1")
ComboBox8.Items.Add("0.2")
ComboBox8.Items.Add("0.5")
ComboBox8.Items.Add("1")
ComboBox8.Items.Add("2")
ComboBox8.Items.Add("3")
ComboBox8.Items.Add("4")
ComboBox8.Items.Add("5")
ComboBox8.Items.Add("6")
ComboBox8.Items.Add("10")
ComboBox8.Items.Add("12")
ComboBox8.SelectedIndex = 5
'===================TrackBar read========================
Dim TBvalue As Integer
TBvalue = TrackBar1.Value
TextBox20.Text = CStr(TBvalue)
'===========Receive check==============
CheckBox9.Checked = True
Button2.Enabled = False
'======Color Combobox ============================
ComboBox9.Items.Add(Color.Red)
ComboBox9.Items.Add(Color.Blue)
ComboBox9.Items.Add(Color.Green)
ComboBox9.Items.Add(Color.Magenta)
ComboBox9.Items.Add(Color.Orange)
ComboBox9.Items.Add(Color.Black)
ComboBox9.SelectedIndex = 0
'============USB Serial Ports Search=============
For Each sp As String In My.Computer.Ports.SerialPortNames
ComboBox10.Items.Add(sp)
ComboBox11.Items.Add(sp)
Next
ComboBox10.Items.Add("None")
ComboBox11.Items.Add("None")
ComboBox11.SelectedIndex = ComboBox11.Items.Count - 1
'==============================COLORS ====================================
TextBox13.BackColor = Color.Red
TextBox14.BackColor = Color.Blue
TextBox15.BackColor = Color.Green
TextBox16.BackColor = Color.Magenta
TextBox17.BackColor = Color.Orange
TextBox18.BackColor = Color.LemonChiffon
TextBox19.BackColor = Color.Lime
TextBox28.BackColor = Color.MediumSpringGreen
TextBox30.BackColor = Color.DeepPink
TextBox32.BackColor = Color.Crimson
TextBox34.BackColor = Color.SeaGreen
TextBox36.BackColor = Color.GreenYellow
TextBox38.BackColor = Color.Orchid
TextBox40.BackColor = Color.Maroon
TextBox42.BackColor = Color.DarkSlateBlue
TextBox44.BackColor = Color.DarkViolet
'p1 = Pens.Red
'p2 = Pens.Blue
'p3 = Pens.Green
'p4 = Pens.Magenta
'p5 = Pens.Orange
'p6 = Pens.Black
'p7 = Pens.Lime
'p8 = Pens.MediumSpringGreen
'p9 = Pens.HotPink
'p10 = Pens.PowderBlue
'p11 = Pens.SeaGreen
'p12 = Pens.Salmon
'p13 = Pens.Orchid
'p14 = Pens.Maroon
'p15 = Pens.DarkSlateBlue
'p16 = Pens.DarkViolet
End Sub
'========================================================================
'================Average Graph mid Data==================================
'========================================================================
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Try
Dim endnum As Integer
Dim startnum As Integer
Dim midave(16) As Double
If dataNo > 200 Then
endnum = dataNo ' CInt(TextBox2.Text)
startnum = endnum - 100
midave = dave(startnum, endnum, CInt(TextBox3.Text))
Debug.Print("AveButtn:" & CStr(startnum) & "," & CStr(endnum) & "," & CStr(midave(0)))
TextBox13.Text = midave(0)
TextBox14.Text = midave(1)
TextBox15.Text = midave(2)
TextBox16.Text = midave(3)
TextBox17.Text = midave(4)
TextBox18.Text = midave(5)
TextBox19.Text = midave(6)
TextBox28.Text = midave(7)
TextBox30.Text = midave(8)
TextBox32.Text = midave(9)
TextBox34.Text = midave(10)
TextBox36.Text = midave(11)
TextBox38.Text = midave(12)
TextBox40.Text = midave(13)
TextBox42.Text = midave(14)
TextBox44.Text = midave(15)
End If
Catch ex As Exception
Console.WriteLine(ex.Message) '例外処理を行います
Console.WriteLine("Error in Average")
End Try
End Sub
'==========================PLOTTING Parameter Check ===============================================
'===================dataAry(,)=mV rate()=dot/mv=1/adjutvalue()(=mV/dot)============================================
'=================== plot: py=(dataAry(,)-midvalue())*rate()+midvalue()==============================================
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim m, n As Integer
Dim px, py As Integer
Dim dn, ds, de As Integer
ReDim rate(8)
ReDim midvalue(8)
'For m = 0 To 6
' rate(m) = 1 / CInt(adjustComboBox(m).Text)
' midvalue(m) = CDbl(midTextBox(m).Text)
'Next
dn = CInt(TextBox2.Text) '現在データNo
ds = CInt(dn / 600) * 600 '左始点データスタートNO
de = dn Mod 600 '現在座標
'Debug.Print("dn=" & CStr(dn) & "ds=" & CStr(ds) & "de=" & CStr(de))
For n = 0 To 5
For m = 0 To de
px = m
py = CInt((CDbl(dataAry(ds + m, n)) - midvalue(n)) * rate(n) / 100 + yh / 2)
'Debug.Print("m=" & CStr(m) & "n=" & CStr(n) & "dataAry=" & CStr(dataAry(ds + m, n)) & "midvalue=" & CStr(midvalue(n)) & "sa=" & CStr((CDbl(dataAry(ds + m, n)) - midvalue(n))) & "rate=" & rate(n) & "Plotting:px=" & CStr(px) & "py=" & CStr(py))
'Debug.Print("Plotting:px=" & CStr(px) & "py=" & CStr(py))
Next
Next
End Sub
'********************************************************************************************************************
'*********************************FORM Reading Functions*************************************************************
'*******************************************************************************************************************
Private Function AvTR() As Double()
Dim ave(16) As Double
ave(0) = CDbl(TextBox13.Text)
ave(1) = CDbl(TextBox14.Text)
ave(2) = CDbl(TextBox15.Text)
ave(3) = CDbl(TextBox16.Text)
ave(4) = CDbl(TextBox17.Text)
ave(5) = CDbl(TextBox18.Text)
ave(6) = CDbl(TextBox19.Text)
ave(7) = CDbl(TextBox28.Text)
ave(8) = CDbl(TextBox30.Text)
ave(9) = CDbl(TextBox32.Text)
ave(10) = CDbl(TextBox34.Text)
ave(11) = CDbl(TextBox36.Text)
ave(12) = CDbl(TextBox38.Text)
ave(13) = CDbl(TextBox40.Text)
ave(14) = CDbl(TextBox42.Text)
ave(15) = CDbl(TextBox44.Text)
Return ave
End Function
Private Function RateCR() As Double()
Dim rate(16) As Double
rate(0) = CDbl(ComboBox1.SelectedItem) 'mv/dot
rate(1) = CDbl(ComboBox2.SelectedItem)
rate(2) = CDbl(ComboBox3.SelectedItem)
rate(3) = CDbl(ComboBox4.SelectedItem)
rate(4) = CDbl(ComboBox5.SelectedItem)
rate(5) = CDbl(ComboBox6.SelectedItem)
rate(6) = CDbl(ComboBox7.SelectedItem)
rate(7) = CDbl(ComboBox12.SelectedItem) 'mv/dot
rate(8) = CDbl(ComboBox13.SelectedItem)
rate(9) = CDbl(ComboBox14.SelectedItem)
rate(10) = CDbl(ComboBox15.SelectedItem)
rate(11) = CDbl(ComboBox16.SelectedItem)
rate(12) = CDbl(ComboBox17.SelectedItem)
rate(13) = CDbl(ComboBox18.SelectedItem)
rate(14) = CDbl(ComboBox19.SelectedItem)
rate(15) = CDbl(ComboBox20.SelectedItem)
Return rate
End Function
Private Function CheckBR() As Integer()
Dim selCh(16) As Integer '= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Dim CH_checkbox() As CheckBox
CH_checkbox = {Me.CheckBox1, Me.CheckBox2, Me.CheckBox3, Me.CheckBox4, Me.CheckBox5, Me.CheckBox6, Me.CheckBox7, Me.CheckBox13, Me.CheckBox14, Me.CheckBox15, Me.CheckBox16, Me.CheckBox17, Me.CheckBox18, Me.CheckBox19, Me.CheckBox20, Me.CheckBox21}
For i = 0 To 15
If CH_checkbox(i).Checked = True Then
selCh(i) = 1
Else
selCh(i) = 0
End If
Next i
Return selCh
End Function
Private Function CheckCH()
Dim CH_checkbox() As CheckBox
CH_checkbox = {Me.CheckBox1, Me.CheckBox2, Me.CheckBox3, Me.CheckBox4, Me.CheckBox5, Me.CheckBox6, Me.CheckBox7, Me.CheckBox13, Me.CheckBox14, Me.CheckBox15, Me.CheckBox16, Me.CheckBox17, Me.CheckBox18, Me.CheckBox19, Me.CheckBox20, Me.CheckBox21}
Dim dataTextBox() As TextBox
dataTextBox = {Me.TextBox4, Me.TextBox5, Me.TextBox6, Me.TextBox7, Me.TextBox8, Me.TextBox9, Me.TextBox10, Me.TextBox29, Me.TextBox31, Me.TextBox33, Me.TextBox35, Me.TextBox37, Me.TextBox39, Me.TextBox41, Me.TextBox43, Me.TextBox45}
Debug.Print("CheckCH Integer Chsuu")
Debug.Print(Chsuu)
For i = 0 To 15
If i < Chsuu Then
CH_checkbox(i).Checked = True
Else
CH_checkbox(i).Checked = False
End If
Next
'For i = 0 To CInt(TextBox3.Text) - 1
' CH_checkbox(i).Checked = True
'Next
'For i = CInt(TextBox3.Text) - 1 To 15
' CH_checkbox(i).Checked = False
' dataTextBox(i).Text = ""
'Next
Label3.Text = "CH selected"
End Function
'*******************************************************************************************************************
'*******************************************************************************************************************
'*******************************************************************************************************************
'==================================================================================================================
'==================================Static Calculation===========================================================
'==========================Ave() MovingAve() ============================================================
'==================================================================================================================
'==================================================================================================================
Function dave(ByVal startN As Integer, ByVal endN As Integer, ByVal ch As Integer) As Double()
Dim chN As Integer
Dim dataN As Integer
Dim dsum As Double
Dim avech() As Double
ReDim avech(16)
Dim dstring As String
dstring = "dave:" + CStr(startN) + "," + CStr(endN) + "," + CStr(ch)
Debug.Print(dstring)
'Try
For chN = 0 To ch - 1 'chは1-6chで与えられるがデータindexは0-5
For dataN = startN To endN 'startNからendNまでendN-startN+1 個の総和をとって平均
dsum += dataAry(dataN, chN)
Next
avech(chN) = dsum / (endN - startN + 1)
dsum = 0
Next
Return avech
'Catch ex As Exception
' Console.WriteLine(ex.Message)
' Console.WriteLine("Error In dave()")
'End Try
End Function
Function MovAve(ByRef dA(,) As Long, ByVal colN As Integer, ByVal MA As Integer, ByVal rowN As Integer) As Double()
Dim i, j As Integer
Dim dataSum() As Long
Dim dSum As Long
Dim dataA() As Double '= {0, 0, 0, 0, 0, 0, 0}
'Debug.Print("====colN=" & CStr(colN) & "MA=" & CStr(MA) & "rowN=" & CStr(rowN))
ReDim dataSum(colN + 1)
ReDim dataA(colN + 1)
For j = 0 To colN - 1
dSum = 0
For i = rowN - MA To rowN
dSum = dSum + dA(i, j)
'Debug.Print("dA(" & CStr(i) & "," & CStr(j) & ")=" & CStr(dA(i, j)) & CStr(dataSum(j)))
Next
dataA(j) = CDbl(dSum / MA)
Next
MovAve = dataA
End Function
Sub AutoFileLog()
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
'===================FILE Name=================
'------FILE SAVE----------------------
Dim sfd As New SaveFileDialog()
Dim fname As String
fname = Format(Now, "yyyyMMdd_HHmmss")
' Debug.Print("fname=" & fname)
sfd.FileName = fname
sfd.Filter = "TXTファイル|*.txt|CSVファイル|*.csv|すべてのファイル|*.*"
sfd.InitialDirectory = "C:\vb_LOG "
sfd.FilterIndex = 2
sfd.Title = "保存先のファイルを選択してください"
If sfd.ShowDialog() = DialogResult.OK Then
'OKボタンがクリックされたとき、選択されたファイル名を表示する
Console.WriteLine(sfd.FileName)
TextBox21.Text = sfd.FileName
End If
End Sub
Private Sub TrackBar1_MouseDown(sender As Object, e As MouseEventArgs) Handles TrackBar1.MouseDown
'Debug.Print("Mouse Downed")
End Sub
'============ Auto File save CheckBox8====================================
Private Sub CheckBox8_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox8.CheckedChanged
If CheckBox8.Checked = False Then
fname = ""
TextBox21.Text = ""
'If System.IO.File.Exists(fname) Then
file.Close()
Label7.Text = "FileClosed"
' End If
End If
End Sub
'=========Receiving CheckBox===============================
Private Sub CheckBox9_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox9.CheckedChanged
If CheckBox9.Checked = False Then
Button2.Enabled = True
Else
Button2.Enabled = False
End If
End Sub
'====Linearuty MODE Controls Visible===============
Private Sub CheckBox10_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox10.CheckedChanged
If CheckBox10.Checked = True Then
TextBox22.Visible = True
TextBox23.Visible = True
TextBox24.Visible = True
TextBox25.Visible = True
TextBox26.Visible = True
TextBox27.Visible = True
Label11.Visible = True
Label12.Visible = True
Label13.Visible = True
Label14.Visible = True
Label15.Visible = True
Label16.Visible = True
Label17.Visible = True
Label18.Visible = True
Label19.Visible = True
End If
If CheckBox10.Checked = False Then
TextBox22.Visible = False
TextBox23.Visible = False
TextBox24.Visible = False
TextBox25.Visible = False
TextBox26.Visible = False
TextBox27.Visible = False
Label11.Visible = False
Label12.Visible = False
Label13.Visible = False
Label14.Visible = False
Label15.Visible = False
Label16.Visible = False
Label17.Visible = False
Label18.Visible = False
Label19.Visible = False
End If
End Sub
Private Sub Button8_Click_1(sender As Object, e As EventArgs) Handles Button8.Click
PictureBox1.Image = Nothing '1スクロール毎に画面クリア
End Sub
Private Sub ComboBox9_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox9.SelectedIndexChanged
Select Case ComboBox9.SelectedIndex
Case 0
ComboBox9.BackColor = Color.Red
ComboBox9.ForeColor = Color.Red
Case 1
ComboBox9.BackColor = Color.Blue
ComboBox9.ForeColor = Color.Blue
Case 2
ComboBox9.BackColor = Color.Green
ComboBox9.ForeColor = Color.Green
Case 3
ComboBox9.BackColor = Color.Magenta
ComboBox9.ForeColor = Color.Magenta
Case 4
ComboBox9.BackColor = Color.Orange
ComboBox9.ForeColor = Color.Orange
Case 5
ComboBox9.BackColor = Color.Black
ComboBox9.ForeColor = Color.Black
End Select
End Sub
Private Sub ComboBox9_Click(sender As Object, e As EventArgs) Handles ComboBox9.Click
ComboBox9.ForeColor = Color.Gray
End Sub
'==========Comment MEMO=====================================
Private Sub Button10_Click(sender As Object, e As EventArgs)
End Sub
Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged
'-------Ellipse Color----------------
Select Case ComboBox9.SelectedIndex
Case 0
RichTextBox1.SelectionColor = Color.Red
Case 1
RichTextBox1.SelectionColor = Color.Blue
Case 2
RichTextBox1.SelectionColor = Color.Green
Case 3
RichTextBox1.SelectionColor = Color.Magenta
Case 4
RichTextBox1.SelectionColor = Color.Orange
Case 5
RichTextBox1.SelectionColor = Color.Black
End Select
End Sub
Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
'shokaiN = 1
End Sub
Private Sub ListBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles ListBox1.MouseDown
Dim sindex As Integer
sindex = ListBox1.SelectedIndex
TextBox12.Text = ListBox1.SelectedItem
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
shokaiN = 1
End Sub
Private Shared _form1Instance As Form1
'Form1オブジェクトを取得、設定するためのプロパティ
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment