题目描述:
是现在一局域网中发送消息(既多ip地址的发送,例如:192.168.1.1-192.168.1.5中)。
以下是给一个ip地址发送:
Private Sub CmdSend_Click()
If Trim(TxtAddress.Text) = "" Then
MsgBox "请输入要发送的目的地", vbOKOnly, "提示", 0, 0
Else
If Trim(TxtTime.Text) = "" Then
MsgBox "请输入要发送的时间间隔", vbOKOnly, "提示", 0, 0
Else
If Trim(TxtContent.Text) = "" Then
MsgBox "请输入要发送的内容", vbOKOnly, "提示", 0, 0
Else
Open App.Path & "\a.bat" For Output As #1
Print #1, "net send " & Trim(TxtAddress.Text) & " " & Trim(TxtContent.Text)
TmSend.Interval = CInt(Trim(TxtTime.Text)) * 1000
TmSend.Enabled = True
Close #1
End If
End If
End If
End Sub如何修改这个程序实现我的目的。
是现在一局域网中发送消息(既多ip地址的发送,例如:192.168.1.1-192.168.1.5中)。
以下是给一个ip地址发送:
Private Sub CmdSend_Click()
If Trim(TxtAddress.Text) = "" Then
MsgBox "请输入要发送的目的地", vbOKOnly, "提示", 0, 0
Else
If Trim(TxtTime.Text) = "" Then
MsgBox "请输入要发送的时间间隔", vbOKOnly, "提示", 0, 0
Else
If Trim(TxtContent.Text) = "" Then
MsgBox "请输入要发送的内容", vbOKOnly, "提示", 0, 0
Else
Open App.Path & "\a.bat" For Output As #1
Print #1, "net send " & Trim(TxtAddress.Text) & " " & Trim(TxtContent.Text)
TmSend.Interval = CInt(Trim(TxtTime.Text)) * 1000
TmSend.Enabled = True
Close #1
End If
End If
End If
End Sub如何修改这个程序实现我的目的。
解决方案 »
- mysql如何在所有表格内搜索某字段的信息
- 急需~求高手指教:如何从vb程序中转到记事本?
- 在VB中如何读取图片中的数字.将其变成数字字符~~~
- 如何清楚MSHFlexGrid单元格中已载入的图片
- 有人用过MS Agent吗?有几个问题想请教
- datareport报表显示时,提示报表宽度大于纸张宽度,该怎么办啊?
- 如何在VB中禁止richtextbox的选择和默认的复制与剪切功能?
- 如何对单元格输入数据锁定
- Chm电子书制作工具,那一款最方便优秀?
- 我想做一个在运行时可以选中调整位置、大小的输入框,和在设计时文本框一样,给点思路
- VB没有反正切三角涵数吗?
- 请问 在珠海有没有专门培训VB的地方?
Dim RemoteIP As String
Dim j As Integer
Dim LastIp As String
LastIp = ""
If ccrpIPAddressEnd.Fields(3).Value <> ccrpIPAddressStart.Fields(3).Value Then
IPNum = (ccrpIPAddressEnd.Fields(3).Value - ccrpIPAddressStart.Fields(3).Value) * 256 + ccrpIPAddressEnd.Fields(4).Value - ccrpIPAddressStart.Fields(4).Value + 1
Else
IPNum = ccrpIPAddressEnd.Fields(4).Value - ccrpIPAddressStart.Fields(4).Value + 1
End If
LastIp = ccrpIPAddressStart.Fields(4).Value
For j = 1 To IPNum
If IPNum <> 1 Then
If ccrpIPAddressStart.Fields(4).Value > 255 Then
ccrpIPAddressStart.Fields(3).Value = ccrpIPAddressStart.Fields(3).Value + 1
ccrpIPAddressStart.Fields(4).Value = 0
RemoteIP = ccrpIPAddressStart.Fields(1).Value & "." & ccrpIPAddressStart.Fields(2).Value & "." & ccrpIPAddressStart.Fields(3).Value & "." & LastIp
LastIp = LastIp + 1
Else
RemoteIP = ccrpIPAddressStart.Fields(1).Value & "." & ccrpIPAddressStart.Fields(2).Value & "." & ccrpIPAddressStart.Fields(3).Value & "." & LastIp
LastIp = LastIp + 1
End If
Else
RemoteIP = ccrpIPAddressStart.Text
End If
......'这里调用你发送信息的方法。
Next j注:ccrpIPAddress是一个IP地址的控件,上面实现的是一个IP地址的循环
在上面的“......‘这里调用你发送信息的方法”这里加上下面的内容。如果你用TextBox作为IP地址的输入。看下面的代码
Open App.Path & "\a.bat" For Output As #1
Print #1, "net send " & Trim(RemoteIP) & " " & Trim(TxtContent.Text)
TmSend.Interval = CInt(Trim(TxtTime.Text)) * 1000
TmSend.Enabled = True
Close #1用TextBox作为IP地址的输入
Public Property Get CheckAddressNum() As Boolean
Dim value1 As String
Dim value2 As String
Dim error_txt As String
Dim Temp As String
Dim RemoteIP As String
Dim j As Integer
value1 = IPSTARADDRESS.Text
value2 = IPENDADDRESS.Text
Dim ip_txt1 As Variant
Dim ip_txt2 As Variant
ip_txt1 = Split(value1, ".")
ip_txt2 = Split(value2, ".")
Dim i As Integer
For i = 0 To UBound(ip_txt1)
error_txt = ""
If CInt(ip_txt1(i)) > CInt(ip_txt2(i)) Then
error_txt = "起始IP地址值要小于截止IP地址值!"
GoTo errormsg
End If
‘IP地址的第三位不同
If i = 2 Then
If CInt(ip_txt1(2)) <> CInt(ip_txt2(2)) Then
IPNum = (ip_txt2(2) - ip_txt1(2)) * 255 + ip_txt2(3) - ip_txt1(3) + 1
Exit For
End If
End If
’IP地址的第四位不同
If i = 3 Then
If CInt(ip_txt1(3)) <> CInt(ip_txt2(3)) Then
IPNum = ip_txt2(3) - ip_txt1(3) + 1
End If
End If
Next i
For j = 0 To IPNum
If ip_txt1(3) > 255 Then
ip_txt1(2) = ip_txt1(2) + 1
ip_txt1(3) = 0
Temp = ip_txt1(0) & "." & ip_txt1(1) & "." & ip_txt1(2) & "." & ip_txt1(3)
RemoteIP = Temp
ip_txt1(3) = ip_txt1(3) + 1
Else
RemoteIP = Left(Me.IPSTARADDRESS, InStrRev(Me.IPSTARADDRESS, ".")) & ip_txt1(3)
ip_txt1(3) = ip_txt1(3) + 1
End If
......'这里调用你发送信息的方法。
Next j
CheckAddressNum = True
Exit Property
errormsg:
MsgBox (error_txt)
CheckAddressNum = False
End Property