《2022年vb上位机程序 .pdf》由会员分享,可在线阅读,更多相关《2022年vb上位机程序 .pdf(12页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、个人中心我的主页好友消息dfgfdhygfh|装扮|设置|退出dfgfdhygfh 文章相册HOHO照片 PK分享投票测试礼物宠物开心部落汽车工厂七彩鱼更多网页游戏添加设置分享热门分享最新分享好友的分享我的分享如何分享?问题反馈天朝的刺猬的分享名师资料总结-精品资料欢迎下载-名师精心整理-第 1 页,共 12 页 -分享VB 上位机控制LED 显示屏源程序此程序用于自己做的P10户外条形屏已经投入使用为 384*32 大小 效果不错,单片机用了STC11F32XE或 STC11F60XE,效果不错Private Sub Combo1_Change()If MSComm1.PortOpen=Tr
2、ue Then 如果串口打开先关闭后再进行其他操作msg$=先关闭后串口再进行其他操作 错误显示Title$=警告 x=MsgBox(msg$,48,Title$)48标示显示警告图标MSComm1.PortOpen=False Else MSComm1.CommPort=Combo1.ListIndex+1 读取 com 口号End If End Sub Private Sub Combo7_Change()displaylab11.FontSize=16 End Sub Private Sub Command1_Click()shuru.Text=Label14.Caption=等待输入数
3、据 End Sub Private Sub Command2_Click()If(wordsize.Text=32)Then Call tiquzi32 End If Label14.Caption=数据发送中 End Sub 名师资料总结-精品资料欢迎下载-名师精心整理-第 2 页,共 12 页 -Private Sub displaylab11_Click()End Sub Private Sub guanyu_Click()MsgBox 版本 0.0 董印 2010!End Sub Private Sub opencom_Click()On Error GoTo uerror 发现错误跳
4、转到错误处理If MSComm1.PortOpen=True Then MSComm1.PortOpen=False opencom.Caption=打开串口 按钮文字改变Shape1.FillColor=&H80FFFF 灯颜色改变Combo1.Enabled=True Combo2.Enabled=True Combo3.Enabled=True Combo4.Enabled=True Combo5.Enabled=True Else MSComm1.PortOpen=True opencom.Caption=关闭串口 Shape1.FillColor=&HFF00&Combo1.Enab
5、led=False Combo2.Enabled=False Combo3.Enabled=False Combo4.Enabled=False Combo5.Enabled=False End If Exit Sub uerror:msg$=无效端口号 错误显示Title$=串口调试助手 名师资料总结-精品资料欢迎下载-名师精心整理-第 3 页,共 12 页 -x=MsgBox(msg$,48,Title$)48标示显示警告图标End Sub Private Sub Form_Load()If MSComm1.PortOpen=True Then MSComm1.PortOpen=False
6、 MSComm1.OutBufferSize=2048 MSComm1.InBufferSize=2048 Else End If Combo1.AddItem COM1 Combo1.AddItem COM2 Combo1.AddItem COM3 Combo1.AddItem COM4 Combo1.AddItem COM5 Combo1.AddItem COM6 Combo1.AddItem COM7 Combo1.AddItem COM8 Combo1.AddItem COM9 Combo1.AddItem COM10 Combo1.AddItem COM11 Combo1.AddIt
7、em COM12 Combo1.AddItem COM13 Combo1.AddItem COM14 Combo1.AddItem COM15 Combo1.AddItem COM16 Combo1.ListIndex=0 MSComm1.CommPort=Combo1.ListIndex+1 MSComm1.Settings=9600,n,8,1 opencom.Caption=打开串口 Shape1.FillColor=&H80FFFF 名师资料总结-精品资料欢迎下载-名师精心整理-第 4 页,共 12 页 -Combo2.AddItem 256000 Combo2.AddItem 128
8、000 Combo2.AddItem 115200 Combo2.AddItem 57600 Combo2.AddItem 38400 Combo2.AddItem 28800 Combo2.AddItem 19200 Combo2.AddItem 14400 Combo2.AddItem 9600 Combo2.AddItem 4800 Combo2.AddItem 2400 Combo3.AddItem 无 none Combo3.AddItem 奇 Odd Combo3.AddItem 偶 Even Combo4.AddItem 6 Combo4.AddItem 7 Combo4.Add
9、Item 8 Combo5.AddItem 1 Combo5.AddItem 2 senddelay.Enabled=False time1=Time date1=Date now1=Now Label16.Caption=Year(Date)&年&Month(Date)&月&Day(Date)&日&vbNewLine&Hour(Time)&时&Minute(Time)&分&Second(Time)&秒 End Sub Private Sub quit_Click()Unload Form1 End Sub Private Sub send_Click()名师资料总结-精品资料欢迎下载-名师精
10、心整理-第 5 页,共 12 页 -Dim hz_array()As Variant Dim temp()As Byte Dim strBuff As String Dim count As Integer Dim i As Integer Dim j As Integer Dim k As Integer Dim start As Integer Dim xiabiao As Integer Dim xunhuan As Integer Dim zhiling(0 To 2)As Byte Dim m As Integer ReDim temp(128)ReDim hz_send(0 To
11、1279)send.Enabled=False If MSComm1.PortOpen=False Then MsgBox 请打开串口 End If On Error GoTo uerror 先发送控制指令zhiling(0)=CByte(sendcount*10+yushu)zhiling(1)=32 zhiling(2)=CByte(speed.Text)MSComm1.Output=zhiling hz_array(0)=Temp(0)每十个字发送一次For i=0 To sendcount If i=sendcount Then xunhuan=yushu ReDim hz_send(
12、0 To 128*yushu-1)Else xunhuan=10 End If For j=1 To xunhuan 名师资料总结-精品资料欢迎下载-名师精心整理-第 6 页,共 12 页 -start=0+128*(j-1)For k=0 To 127 xiabiao=start+128*10*i+k hz_send(start+k)=hz_buff(xiabiao)Next Next MSComm1.Output=hz_send Next For j=1 To yushu 不足十个字的又发送一次 start=0+128*(j-1)For k=0 To 127 xiabiao=start+1
13、28*10*sendcount+k hz_send(start+k)=hz_buff(xiabiao)Next Next MSComm1.Output=hz_send senddelay.Enabled=True Label14.Caption=发送成功 Label14.Caption+1Len(strBuff)发送计数MsgBox 发送完毕,可以安全退出了!senddelay.Enabled=True uerror:End Sub Private Sub Text1_Change()displaylab11.Caption=Left(Text1.Text,12)&vbNewLine&Mid(
14、Text1.Text,13,12)&Mid(Text1.Text,25,12)&Mid(Text1.Text,37,12)End Sub Private Sub senddelay_Timer()Label14.Caption=发送成功 名师资料总结-精品资料欢迎下载-名师精心整理-第 7 页,共 12 页 -send.Enabled=False senddelay.Enabled=False End Sub Private Sub shuru_Change()display.Caption=Left(shuru.Text,12)&vbNewLine&Mid(shuru.Text,13,12)
15、&vbNewLine&Mid(shuru.Text,25,12)&vbNewLine&Mid(shuru.Text,37,12)End Sub Private Sub state_Click()MsgBox 详情请查看该文件夹下的帮助文件 End Sub Private Sub teshu_Click()Dim temp As Variant temp=Shell(C:WINDOWSSYSTEM32notepad.exe,1)Shell notepad.exe readme.txt,vbNormalFocus End Sub Private Sub Timer1_Timer()If Combo
16、3=无 none Then MSComm1.Settings=Str(Combo2)+N+Str(Combo4)+Str(Combo5)ElseIf Combo3=奇 Odd Then MSComm1.Settings=Str(Combo2)+O+Str(Combo4)+Str(Combo5)ElseIf Combo3=偶 Even Then MSComm1.Settings=Str(Combo2)+E+Str(Combo4)+Str(Combo5)End If time1=Time date1=Date now1=Now Label16.Caption=Year(Date)&年&Month(
17、Date)&月&Day(Date)&日&vbNewLine&Hour(Time)&时&Minute(Time)&分&Second(Time)&秒 End Sub Private Sub world1_Change()End Sub 名师资料总结-精品资料欢迎下载-名师精心整理-第 8 页,共 12 页 -Private Sub worldsize1_DropDown()displaylab10.Caption=第一页数据:左移方式最多输入200个字 End Sub Private Sub tiquzi32()Dim temp As Integer Dim strBuff As String D
18、im i,j,k,c1,c2,m As Integer Dim p1,p2,dot_matrix As Byte Dim location As Long Dim hz_buff_temp()As Byte Dim handle As Integer Dim hz_temp As String Dim length As Integer Dim arraystart As Integer Dim arrayend As Integer Dim sendcount As Integer dot_matrix=32 handle=FreeFile length=Len(shuru.Text)获取当
19、前输入文本的长度On Error GoTo qingshuru sendcount=(length/10-0.5)每十个字发送一次yushu=length Mod 10 ReDim hz_buff(0 To length*128-1)提取点阵存放数组For m=1 To length hz_temp=Mid(shuru.Text,m,1)k=Asc(hz_temp)p1=CByte(65536+k)256)p2=CByte(65536+k)Mod 256)c1=CStr(p1)-&HA1 c2=CStr(p2)-&HA1 rec=c1*94+c2 location=CLng(rec)*dot_
20、matrix*4+1 ReDim hz_buff_temp(0 To 4*dot_matrix-1)名师资料总结-精品资料欢迎下载-名师精心整理-第 9 页,共 12 页 -Select Case hz_ziti.Text 获取当前选中的字体Case 宋体 zk_file=App.Path+ziku+宋体 32.印 Open zk_file For Binary Access Read As#handle Get#handle,location,hz_buff_temp Close#handle Case 行楷 zk_file=App.Path+ziku+微软行楷 32.印 Open zk_f
21、ile For Binary Access Read As#handle Get#handle,location,hz_buff_temp Close#handle Case 粗宋 zk_file=App.Path+ziku+粗宋 32.印 Open zk_file For Binary Access Read As#handle Get#handle,location,hz_buff_temp Close#handle Case 黑体 zk_file=App.Path+ziku+黑体 32.印 Open zk_file For Binary Access Read As#handle Get
22、#handle,location,hz_buff_temp Close#handle Case 隶书 zk_file=App.Path+ziku+微软隶书 32.印 Open zk_file For Binary Access Read As#handle Get#handle,location,hz_buff_temp Close#handle Case 长城行楷 zk_file=App.Path+ziku+长城行楷 32.印 Open zk_file For Binary Access Read As#handle Get#handle,location,hz_buff_temp Clos
23、e#handle Case 水波 zk_file=App.Path+ziku+迷你水波 32.印 Open zk_file For Binary Access Read As#handle Get#handle,location,hz_buff_temp 名师资料总结-精品资料欢迎下载-名师精心整理-第 10 页,共 12 页 -Close#handle End Select arraystart=0+128*(m-1)arrayend=127+128*(m-1)For i=0 To 4*dot_matrix-1 hz_buff(arraystart+i)=Not hz_buff_temp(i
24、)Next Next send.Enabled=True Exit Sub qingshuru:MsgBox 请输入汉字 End Sub Private Sub Timer2_Timer()shuoming.Visible=False Timer2.Enabled=False End Sub 来自:http:/ 23:07 评论:1条投票:0次名师资料总结-精品资料欢迎下载-名师精心整理-第 11 页,共 12 页 -本贴分享:3 累计分享:5 共有 0人发表观点.目前还没有互动观点,输入您的互动观点天朝的刺猬的相关分享:数控直流恒流源转用 VC+6.0 实现 PC 机与单片机之间的数据.Proteus 中元件库的中英对照及快捷键操作51单片机汇编语言教程:7课:单片机的特殊功.评论(1)表情同时分享给好友2010 年11月29日 23:07 天朝的刺猬难得有开源的谢谢你楼主帮助中心|空间客服|投诉中心|空间协议|联系我们2006-2011?Baidu 名师资料总结-精品资料欢迎下载-名师精心整理-第 12 页,共 12 页 -