Visual_Basic 板


LINE

※ 引述《quanyong (万般皆是命阿)》之铭言: : ※ 引述《fumizuki (蒙面加菲狮)》之铭言: : : 要加入啊,不然 vb怎麽知道 MSComm1 是什麽东西 : : 不过,MSComm的类型是控制项,是要挂在表单上的, : : 不知道 ActiveX DLL 可不可以这样子用@@ : : 如果设定加入MSComm,测试不行的话,程式开始加上这一行: : : Set MSComm1 = CreateObject("MSCommLib.MSComm") : : VB6范例: : : Sub Open() : : '如果加入使用元件不行再试试看下面这一行 : : 'Set MSComm1 = CreateObject("MSCommLib.MSComm") : : '其他必要的程式码自己再加上去 : : If Not (MSComm1.PortOpen) Then : : MSComm1.PortOpen = True '开启串列连接埠 : : End If : : End Sub : : Sub Close() : : If MSComm1.PortOpen Then : : MSComm1.PortOpen = False '关闭串列连接埠 : : End If : : End Sub : : Function GetData() : : GetData = MSComm1.Input : : End Function : : 网页端范例: : : Set myobj = Server.CreateObject("MyProject.MyClass") '建立物件 : : myobj.Open() '开启连接埠 : : Response.Write(myobj.GetData()) '取得资料 : : myobj.Close() '关闭连接埠 : : Set myobj = Nothing '释放物件 : 不好意思 : 再请问你 : 你说的必要程式码是我原本打的MSCOMM通讯项的原始程式码吗 : 然後程式编排就像你上面打的那样吗 : 我照这样打过了 : 还是不能制成.DLL档案 : 我是不是哪里有打错ㄚ : 因为我要制成.DLL档案时 : 然後第一排的Sub Open() : 它显示"必须是识别项" : 我也看不出来哪里出问题 : 再拜托高手大大你了 : 谢谢你 : 以下是我完整的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 : End Sub ^^^^^^^^^ : If Not (MSComm1.PortOpen) Then : MSComm1.PortOpen = True '开启串列连接埠 : End If : End Sub ^^^^^^^^^^ 哪一个 end sub 是多的? : 拜托您了 -- ▃▅▇▆▄ ▆▂▃ ` 逝去感如何能留住,半点遗留殊不易,██▅▇▄▃ ▇▃▂" . █████████▃i ▁▄▇ 更多凄凄惨惨的遭遇………██▆▃ █▅▆▃ˍ▄* ▂█▄▇▅▂. 我不知道,王~八~蛋~~! ▂▆███ █▄▃ 。fumizuki。Check。 --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.194.224.174







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Tech_Job站内搜寻

TOP