Hi, thx to jax_man that i converted my code to vb.net but the problem now is that the program don't seem to work. The button when i clicked on don't work. sorry i'm new to programming.
hanes84 0 Newbie Poster
The attachment preview is chopped off after the first 10 KB. Please download the entire file.
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Text1 As System.Windows.Forms.TextBox
Friend WithEvents Command3 As System.Windows.Forms.Button
Friend WithEvents Command4 As System.Windows.Forms.Button
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Command2 As System.Windows.Forms.Button
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Text1 = New System.Windows.Forms.TextBox
Me.Command3 = New System.Windows.Forms.Button
Me.Command4 = New System.Windows.Forms.Button
Me.Label3 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me.Command2 = New System.Windows.Forms.Button
Me.Label2 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Text1
'
Me.Text1.BackColor = System.Drawing.SystemColors.Window
Me.Text1.ForeColor = System.Drawing.SystemColors.WindowText
Me.Text1.Location = New System.Drawing.Point(210, 105)
Me.Text1.Name = "Text1"
Me.Text1.Size = New System.Drawing.Size(106, 20)
Me.Text1.TabIndex = 3
Me.Text1.Text = "COM5"
'
'Command3
'
Me.Command3.BackColor = System.Drawing.SystemColors.Control
Me.Command3.ForeColor = System.Drawing.SystemColors.ControlText
Me.Command3.Location = New System.Drawing.Point(113, 97)
Me.Command3.Name = "Command3"
Me.Command3.Size = New System.Drawing.Size(82, 41)
Me.Command3.TabIndex = 2
Me.Command3.Text = "Wireless"
Me.Command3.UseVisualStyleBackColor = False
'
'Command4
'
Me.Command4.BackColor = System.Drawing.SystemColors.Control
Me.Command4.ForeColor = System.Drawing.SystemColors.ControlText
Me.Command4.Location = New System.Drawing.Point(332, 97)
Me.Command4.Name = "Command4"
Me.Command4.Size = New System.Drawing.Size(82, 41)
Me.Command4.TabIndex = 0
Me.Command4.Text = "Command4"
Me.Command4.UseVisualStyleBackColor = False
'
'Label3
'
Me.Label3.BackColor = System.Drawing.SystemColors.Control
Me.Label3.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label3.Location = New System.Drawing.Point(23, 275)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(163, 41)
Me.Label3.TabIndex = 6
'
'Label1
'
Me.Label1.BackColor = System.Drawing.SystemColors.Control
Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label1.Location = New System.Drawing.Point(24, 165)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(139, 25)
Me.Label1.TabIndex = 4
'
'Command2
'
Me.Command2.Location = New System.Drawing.Point(27, 106)
Me.Command2.Name = "Command2"
Me.Command2.Size = New System.Drawing.Size(75, 23)
Me.Command2.TabIndex = 7
Me.Command2.Text = "END"
Me.Command2.UseVisualStyleBackColor = True
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(24, 201)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(137, 42)
Me.Label2.TabIndex = 8
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(32, 28)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(433, 43)
Me.Label4.TabIndex = 9
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(527, 362)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Command2)
Me.Controls.Add(Me.Text1)
Me.Controls.Add(Me.Command3)
Me.Controls.Add(Me.Command4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label1)
Me.ForeColor = System.Drawing.SystemColors.ControlText
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
'=========================================================
Private Sub Command3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Command3.Click
'#Const def_Command3_Click = True
#If def_Command3_Click
Dim myErr As Object ' - "AutoDim"
On Error GoTo errHand
' check comm port
If Trim(Text1.Text)="" Then Label2.Text = "Cannot start without COMM port." : Exit Sub
Text1.Text = UCase(Trim(Text1.Text))
Rem()
kshandle = CreateKinetiSense()
daqH = 1
myErr = StartCommunication(kshandle, Text1.Text, 0)
Application.DoEvents()
If myErr=1 Then Label2.Text = "Communication started"
If myErr<>1 Then
Label2.Text = "Communication fail"
myErr = DestroyKinetiSense(kshandle)
daqH = 0
Exit Sub
End If
daqC = 1
Rem()
myErr = StartAcquisition(kshandle)
Application.DoEvents()
If myErr=1 Then Label2.Text = "DAQ started"
If myErr<>1 Then
Label2.Text = "DAQ fail"
myErr = StopCommunication(kshandle)
Application.DoEvents()
myErr = DestroyKinetiSense(kshandle)
daqH = 0
daqC = 0
Exit Sub
End If
daqS = 1
Rem()
oExcel = CreateObject("Excel.Application")
oBook = oExcel.workbooks.Add
oSheet = oBook.worksheets(1)
' heading
oSheet.range("A1.I1").columnwidth = "15"
oSheet.range("A1.I1").entirecolumn.HorizontalAlignment = 3
'oSheet.range("B1.E1").mergecells = True
oSheet.range("B1").HorizontalAlignment = 1
oSheet.range("B1").Value = "Acceleration(A) measurements in directional axis (x,y,z) are as multiplier of G (gravity constant). Range +/-6G."
oSheet.range("B2").HorizontalAlignment = 1
oSheet.range("B2").Value = "Rotational(W) measurements about the directional axis are in degrees/second. Range +/-1400deg/s."
oSheet.range("B3").HorizontalAlignment = 1
oSheet.range("B3").Value = "EMG measurements are in microvolts(uV). Range +/-5000uV."
oSheet.range("B4").Value = "A(x)"
oSheet.range("C4").Value = "A(y)"
oSheet.range("D4").Value = "A(z)"
oSheet.range("E4").Value = "W(x)"
oSheet.range("F4").Value = "W(y)"
oSheet.range("G4").Value = "W(z)"
oSheet.range("H4").Value = "EMG1 (yellow)"
oSheet.range("I4").Value = "EMG2 (blue)"
Rem()
ctrExcel = 5
oBook.application.Visible = True
Rem()
DAQhereW:
Sleep((100))
Application.DoEvents()
' VBto upgrade warning: noRead As Integer OnWrite(Short)
Dim noRead As Integer
Dim numRead As Integer
Dim numInput As Integer
Dim dlFin As Integer
noRead = 128
' init
'For i = 0 To 31: buffer(i) = 0: Next i
Rem()
myErr = GetData(kshandle, buffer(0), noRead, numRead, numInput)
Application.DoEvents()
Label3(0) = "Status (1)=ok (0)=no data: " & myErr
Label3(1) = "No. of data collected : " & numRead
Label3(2) = "No. of columns : " & numInput
' debug use
'Debug.Print "getData "; myErr
'Debug.Print "numRead "; numRead
'Debug.Print "numInput "; numInput
'Debug.Print "download Stat "; dlFin
'For i = 0 To 63: Debug.Print buffer(i): Next i
Rem()
If myErr=1 Then
If numRead=noRead And numInput=8 Then
For i = 0 To 63 Step 8
oSheet.range("A" & ctrExcel) = TimeOfDay
oSheet.range("B" & ctrExcel) = buffer(i)
oSheet.range("C" & ctrExcel) = buffer(i+1)
oSheet.range("D" & ctrExcel) = buffer(i+2)
oSheet.range("E" & ctrExcel) = buffer(i+3)
oSheet.range("F" & ctrExcel) = buffer(i+4)
oSheet.range("G" & ctrExcel) = buffer(i+5)
oSheet.range("H" & ctrExcel) = buffer(i+6)
oSheet.range("I" & ctrExcel) = buffer(i+7)
ctr
hanes84 0 Newbie Poster
sorry it's Jx_man not jax_man
Jx_Man 987 Nearly a Senior Poster Featured Poster
hmm...it's the demo/trial version...
you just can convert 100 line of project (if i not wrong).
you must to pay to get the full version..i m sorry.
ericstenson 5 Posting Whiz in Training Team Colleague
there are plenty of free converters online. i think there might also be one from MSFT.
hanes84 0 Newbie Poster
thx a lot. searching for it
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.