Home > Software engineering >  Turn to the great god, I am a rookie, a help to see if the code is what mean
Turn to the great god, I am a rookie, a help to see if the code is what mean

Time:09-18

Novice one, never contact the VB code idea is the VB as the client, read WiFi server data, read data format is MAC: * * MVPP: * * * * mv; And draw on axis into amplitude-frequency curve, beg god help ah
 
Dim receive_data (257) As the String
Dim myArray on (2) As String
Dim X (20) As String
Dim MyCaption (20) As String
Dim X1 As Single, Y1 As Single
Dim X2 As Single, Y2 As Single


Public Sub RefreshGraph ()
Dim MyColor (2) As Long
Dim MyLegend (0) As String
Dim As Integer I
For I=1 To 20
MyCaption (I)=I

Next I

MyColor (0)=vbRed

Chart1. MinValue=https://bbs.csdn.net/topics/0
Chart1. 20 Rows=
Chart1. Cols=20
Chart1. DrawGraph myArray on MyColor, MyCaption

MyLegend (0)="amplitude frequency acquisition figure
"
Chart1. DrawLegend MyLegend, MyColor
End Sub

Private Function InsertDB (ByVal table_name As String, ByVal value As a String) As Byte
On Error GoTo gperror

Dim objCn As New ADODB. Connection
Dim objRs As New ADODB. You
Dim strCn As String
Dim strSQL As String
'database connection parameters variables myArray on (0)=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 "
Dim As Integer I
For I=1 To 20
X="0" (20)

Next I
Chart1. MaxValue=https://bbs.csdn.net/topics/2000

RefreshGraph
Dim db_host As String
Dim db_user As String
Dim db_pass As String
Dim db_data As String
'initialize database connection variable
Db_host="127.0.0.1"
Db_user="root"
Db_pass="root"
Db_data="https://bbs.csdn.net/topics/fupin"
ObjCn. The ConnectionString="DRIVER={MySQL ODBC DRIVER 5.1};" & _
"SERVER=" & amp; Db_host & amp; ";" & _
"The DATABASE=" & amp; Db_data & amp; ";" & _
"UID=" & amp; Db_user & amp; "; The PWD="& amp; Db_pass & amp; ";" & _
"OPTION=3; STMT=SET NAMES GB2312 "

ObjCn. Open


StrSQL="INSERT INTO" + fupinshuju + "(MAC, VPP) VALUES (" + CRH (34) + MAC + CRH (34) +", "+ CRH (34) + VPP + CRH (34) +");"
The Set objRs. ActiveConnection=objCn
ObjRs. Open (strSQL)


'close the database connection, release object
ObjCn. Close
The Set objRs=Nothing
The Set objCn=Nothing
The Exit Function

Gperror:
Check_PassWord=255
The Set objRs=Nothing
The Set objCn=Nothing
End the Function

Private Sub CmdSend_Click ()
If (tcpserver. State=7) Then
Tcpserver. SendData publishes the event txtSend. Text
TxtSend. Text=""
End the If

End Sub

Private Sub CmdStart_Click ()


If (tcpserver. State & lt;> 7) Then
Tcpserver. Close
Tcpserver. Connect txtIP. Text, txtPort. Text
'tcpserver. Connect "127.0.0.1," txtPort
The Else
Tcpserver. Close
CmdStart. Caption="connectivity"
TxtIP. Enabled=True
TxtPort. Enabled=True
TxtIP. BackColor=& amp; H80000005
TxtPort. BackColor=& amp; H80000005
End the If

End Sub



Private Sub Form_Load ()
Me, Left=Screen Width/2 - Me. Width/2
Me. Top=Screen. Height/2 - Me. Height/2 'under the full Screen to form center



'txtIP. Text=tcpserver. LocalIP
TxtIP. Text="192.168.4.1"
TxtPort. Text=8086

If (tcpserver. State & lt;> 7) Then
CmdStart. Caption="connectivity"
TxtIP. Enabled=True
TxtPort. Enabled=True
TxtIP. BackColor=& amp; H80000005
TxtPort. BackColor=& amp; H80000005
The Else
CmdStart. Caption="disconnect service
"End the If

,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 MyCaption (0)="0"
Dim As Integer I
For I=1 To 20
X (I)="0"

Next I
Chart1. MaxValue=https://bbs.csdn.net/topics/2000

RefreshGraph 'refresh

'txtMQ2. Text=pm25 (1) + ", "+ pm25 (2) +", "+ pm25 (3) +", "+ pm25 (4) +", "+ pm25 (5) +", "+ pm25 (6) +", "+ pm25 (7) +", "+ pm25 (8) +", "+ pm25 (9) +", "+ pm25 (10)

End Sub

Private Sub Form_Unload (Cancel As Integer)
Tcpserver. Close
End Sub



Private Sub tcpserver_Close ()
Tcpserver. Close
CmdStart. Caption="connectivity"
TxtIP. Enabled=True
TxtPort. Enabled=True
TxtIP. BackColor=& amp; H80000005
TxtPort. BackColor=& amp; H80000005
End Sub

Private Sub tcpserver_Connect ()
CmdStart. Caption="disconnect service
"TxtIP. Enabled=False
TxtPort. Enabled=False
TxtIP. BackColor=& amp; H80000000
TxtPort. BackColor=& amp; H80000000
End Sub

Private Sub tcpserver_ConnectionRequest (ByVal requestID As Long)

If tcpserver. State & lt;> SckClosed Then
Tcpserver. Close
End the If
Tcpserver. Accept requestID

End Sub

Private Sub tcpserver_DataArrival (ByVal bytesTotal As Long)

Dim the value As a String
Static As Integer k
Dim j As Integer
Dim f As String
Dim v As String
K=tcpserver. BytesReceived
VbByte tcpserver. GetData receive_data (0), k 'read from the k in receive_data, type is a byte of data read
Value=(0)
https://bbs.csdn.net/topics/receive_data

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related