|

楼主 |
发表于 2014-10-10 08:55:08
|
显示全部楼层
ntwhq 发表于 2014-10-9 10:18 
用电脑作上位机来控制信号发生器,很强大,我以前也编过用电脑通过串口控制单机的程序,但当时没有实 ...
谢谢版主的关注!这是引导窗口的代码,检测串口- Option Explicit
- Private Function QiDong(slika As PictureBox, StartX As Integer, StartY As Integer, Levo As Integer, Desno As Integer, Boja As String)
- Dim Proba, Proba2 As Integer
- Dim Boja2 As String
- Me.ScaleMode = vbPixels
- With slika
- .ScaleMode = vbPixels
- .AutoRedraw = True
- End With
- For Proba2 = 0 To slika.ScaleWidth
- DoEvents
- For Proba = 0 To slika.ScaleHeight
- Boja2 = slika.Point(Proba2, Proba)
- Line (StartX, StartY)-(Levo + Proba2, Desno + Proba), Boja2
- Next
- Line (StartX, StartY)-(Levo + Proba2, Desno + slika.ScaleHeight), Boja
- Next
- For Proba2 = 0 To slika.ScaleHeight
- Line (StartX, StartY)-(Levo + slika.ScaleWidth, Desno + Proba2), Boja
- Next
- End Function
- Private Sub Form_Load()
- If App.PrevInstance Then MsgBox "本程序已经在运行!请不要重复启动,避免浪费系统资源。", vbOKOnly, "亲爱的朋友:": End
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- '
- End Sub
- Private Sub Timer1_Timer()
- QiDong Picture1, 476, 220, 0, 0, Me.BackColor
- If Timer1.Interval = 1000 Then
- ' frmAdministrator.Show
- Unload Me
- End If
- 'Dim Xi As Integer
- 'For Xi = 0 To 5
- 'ADWinP(Xi) = 0
- 'Next Xi
- Fm.Show
- Dim Ci, Sj As Integer
- Sj = 0
- For Ci = 1 To 16
- Fm.MSComm1.CommPort = Ci
- On Error Resume Next
- Fm.MSComm1.PortOpen = True
- If Err.Number = 0 Then
- Sj = Sj + 1
- Else
- Fm.MSComm1.PortOpen = False
- End If
- Next Ci
- If Sj = 0 Then
- MsgBox "亲爱的朋友!在您的计算机上没有发现串口哦,请检查驱动及硬件设备!"
- Else
- MsgBox "亲爱的朋友!在您的计算机上共搜索到: " & Sj & "个串口。"
- End If
- End Sub
复制代码 |
|