作者quanyong (万般皆是命阿)
看板Visual_Basic
标题Re: ListBox里面显示的资料有办法直接显示在网页上吗
时间Thu May 3 10:30:41 2007
Sub Open()
Set MSComm1 = CreateObject("MSCommLib.MSComm")
Option Explicit
Private Const LB_SETHORIZONTALEXTENT = &H194
'宣告一个DLL内的外部程序
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Dim TempStr As String '用於读取暂存区资料
Dim TempBool As Boolean '判断资料是否已读取完毕
Private Sub Command1_Click()
'===将字串输出,在字串的前面加上字串长度与分隔字元===
If LTrim(Text1.Text) <> "" Then
MSComm1.Output = Len(Text1.Text) & "&RFID:" & Text1.Text
Text1.Text = ""
End If
End Sub
Private Sub Command2_Click()
Text1.Text = ""
End Sub
Private Sub Form_Load()
'===设定、开启串列连接埠===
With MSComm1
.CommPort = 1 '设定串列连接埠代号
.Handshaking = comXOnXoff
.NullDiscard = True
.RThreshold = 1
If Not (.PortOpen) Then
.PortOpen = True '开启串列连接埠
End If
End With
End Sub
Private Sub MSComm1_OnComm()
'===读取接收暂存区中的资料===
Dim TempLong As Long
Dim MaxLength As Integer '记录ListBox中的最大字串长度
Dim TempIndex As Integer '记录ListBox中最长字串的索引值
If TempBool And MSComm1.CommEvent = comEvReceive Then
TempStr = MSComm1.Input
'判断目前取得资料是否为所有资料
If Val(TempStr) + 3 = Len(TempStr) - InStr(1, TempStr, "&") Then
List1.AddItem Mid(TempStr, InStr(1, TempStr, "&") + 1), 0
TempStr = ""
MaxLength = Len(List1.List(0))
For TempLong = 0 To List1.ListCount - 1 '寻找最长字串
If Len(List1.List(TempLong)) >= MaxLength Then
TempIndex = TempLong
MaxLength = Len(List1.List(TempLong))
End If
Next TempLong
'产生一个水平卷轴
Call SendMessage(List1.hwnd, LB_SETHORIZONTALEXTENT, _
ByVal TextWidth(List1.List(TempIndex)) / 14.8, ByVal 0&)
Else
MSComm1.RThreshold = Val(TempStr) + 20 - Len(TempStr) + _
InStr(1, TempStr, "&") '设定最小接收字元数为尚未读取字元数
'去除字串长度与分隔字元
TempStr = Mid(TempStr, InStr(1, TempStr, "&") + 1)
TempBool = False
End If
Else
List1.AddItem TempStr + MSComm1.Input, 0
TempStr = ""
TempBool = True
MSComm1.RThreshold = 1
MaxLength = Len(List1.List(0))
For TempLong = 0 To List1.ListCount - 1
If Len(List1.List(TempLong)) >= MaxLength Then
TempIndex = TempLong
MaxLength = Len(List1.List(TempLong))
End If
Next TempLong
Call SendMessage(List1.hwnd, LB_SETHORIZONTALEXTENT, _
ByVal TextWidth(List1.List(TempIndex)) / 14.8, ByVal 0&)
End If
If Not (MSComm1.PortOpen) Then
MSComm1.PortOpen = True '开启串列连接埠
End If
End Sub
Function GetData()
GetData = MSComm1.Input
End Function
上述程式是我照您给我的范例和问过你又改正过的程式打的
可是要制成.DLL档时还是显示编辑错误 必须是识别项
好苦恼 进度好紧张
不知道又是哪里出问题
拜托大大帮我除错一下
感谢您
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.116.85.178