找回密码
 注册

QQ登录

只需一步,快速开始

搜索

VB开发的串口与三菱FX PLC通讯源码

[复制链接]
coolice 发表于 2020-4-25 15:50:20 | 显示全部楼层 |阅读模式
1.jpg
  1. Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.         lblTopic = "输入要监控或设置的地址回车确定,如D0,T10,Y7等"
  3. End Sub

  4. Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
  5.         If KeyCode <> 13 Then
  6.             start = False
  7.         End If
  8. End Sub

  9. Private Sub Text2_KeyPress(KeyAscii As Integer)
  10.     char = Chr(KeyAscii)
  11.     KeyAscii = Asc(UCase(char))
  12.     If Device = "D" And CStr(Val(setad)) = setad And Val(setad) < 1000 Then
  13.         start = False
  14.     End If
  15.     If (Device = "T" Or Device = "C") And CStr(Val(setad)) = setad And Val(setad) < 256 Then
  16.         start = False
  17.     End If
  18.     If KeyAscii = 13 Then
  19.       If Val(DevAdd) > 7999 Then
  20.          If MsgBox("改变系统参数可能对系统造成破坏,是否写入?", vbOKCancel + vbCritical) = vbCancel Then Exit Sub
  21.       ElseIf MsgBox("改变当前值可能对运行造成危险,是否写入?", vbOKCancel + vbExclamation) = vbCancel Then Exit Sub
  22.       End If
  23.             If Device = "D" And Check1.Value = 0 Then
  24.                 DevAdd = Right(("0000" + setad), 4)
  25.             ElseIf Device = "D" And Check1.Value = 1 Then
  26.                 DevAdd = Right(("0000" + setad), 4)
  27.             Else
  28.                 DevAdd = Right(("000" + setad), 3)
  29.             End If
  30.             If OptionD.Value Then '十进制方式
  31.                 If Device = "C" And Val(setad) > 199 Then 'C200以上写入
  32.                     If Val(Text2.Text) > 2847483647# Then: GoTo this
  33.                     DevDat1 = cboStation.Text + "FFWW0" + Device + "N" + DevAdd + "01" + Right("00000000" + Hex(Val(Text2.Text)), 8)
  34.                 ElseIf Device = "D" And Check1.Value = 1 Then '双字节D写入
  35.                     If Val(Text2.Text) > 2847483647# Then: GoTo this
  36.                     DevDat1 = Right("00000000" + Hex(Val(Text2.Text)), 8)
  37.                     DevDat1 = Right(DevDat1, 4) + Left(DevDat1, 4)
  38.                     DevDat1 = cboStation.Text + "FFWW0" + Device + DevAdd + "02" + DevDat1
  39.                 Else
  40.                     If Val(Text2.Text) > 32767 Then: GoTo this
  41.                     If Device = "D" Then '单字节D写入
  42.                         DevDat1 = cboStation.Text + "FFWW0" + Device + DevAdd + "01" + Right("0000" + Hex(Val(Text2.Text)), 4)
  43.                     Else 'C200以下写入
  44.                         DevDat1 = cboStation.Text + "FFWW0" + Device + "N" + DevAdd + "01" + Right("0000" + Hex(Val(Text2.Text)), 4)
  45.                     End If
  46.                 End If
  47.             Else '十六进制方式
  48.                 If Device = "C" And Val(setad) > 199 Then 'C200以上写入
  49.                     If Val("&H" + Text2.Text) > 2847483647# Then: GoTo this
  50.                     DevDat1 = cboStation.Text + "FFWW0" + Device + "N" + DevAdd + "01" + Right("00000000" + Text2.Text, 8)
  51.                 ElseIf Device = "D" And Check1.Value = 1 Then '双字节D写入
  52.                     If Val("&H" + Text2.Text) > 2847483647# Then: GoTo this
  53.                     DevDat1 = Right("00000000" + Text2.Text, 8)
  54.                     DevDat1 = Right(DevDat1, 4) + Left(DevDat1, 4)
  55.                     DevDat1 = cboStation.Text + "FFWW0" + Device + DevAdd + "02" + DevDat1
  56.                 Else
  57.                     If Val("&H" + Text2.Text) > 32767 Then: GoTo this
  58.                     If Device = "D" Then '单字节D写入
  59.                         DevDat1 = cboStation.Text + "FFWW0" + Device + DevAdd + "01" + Right("0000" + Text2.Text, 4)
  60. ……………………

  61. …………限于本文篇幅 余下代码请下载附件…………
复制代码
VB开发的串口与三菱FX PLC通讯源码.rar (19.54 KB, 售价: 5 E币)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|ELEOK |网站地图

GMT+8, 2024-4-20 17:45

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表