源码天空

时间:2024-09-12 04:41:11编辑:分享君

VB程序源码如何使用

你需要安装vb6.0开发软件
如果安装了,就可以直接打开源码测试了,后缀名是vbp,(就是vb的工程文件)
如果没有安装vb6.0,还想打开源码看程序,那就右击 用记事本 打开后缀名为frm的文件,他是vb的窗口文件,源码都在他里面

一般得源码是没有生成exe可执行文件的,那样文件太多,太大,浪费空间
如果你自己想生成exe可执行文件,那就vb6.0得文件菜单中把文件保存成exe可执行文件就可以了,非常简单
好运!


vb端口映射的程序源码

Option Explicit

Dim bMsg() As Byte

Private Sub Form_Load()

Dim strCTemp As String
Dim intCPTemp As Variant

'侦听端口
Winsock1.LocalPort = 2000
Winsock1.Listen

'向Sphere转发数据
Winsock2.RemoteHost = "127.0.0.1"
Winsock2.RemotePort = 2001
Winsock2.Connect

Do While Winsock2.State 7
If Winsock2.State = 9 Or Winsock2.State = 0 Then Winsock2.Close: Exit Do

Select Case Winsock2.State
Case 1
strCTemp = "已打开!"
Case 2
strCTemp = "正在侦听.."
Case 3
strCTemp = "与服务器连接挂起!"
Case 4
strCTemp = "正在识别主机.."
Case 5
strCTemp = "已识别主机!"
Case 6
strCTemp = "正在与服务器连接.."
Case 8
strCTemp = "同级人员正在关闭连接.."
Case 9
strCTemp = "出错"
Winsock2.Close
End Select

If Winsock2.State intCPTemp Then
intCPTemp = Winsock2.State & vbCrLf
Text1.Text = Text1.Text & strCTemp & vbCrLf
End If

DoEvents
Loop
If Winsock2.State = 7 Then
Text1.Text = Text1.Text & strCTemp & "已成功连接上服务器..." & vbCrLf
End If

End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)

If Winsock1.State sckClosed Then Winsock1.Close
Winsock1.Accept requestID

End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

ReDim bMsg(bytesTotal)
Winsock1.GetData bMsg
Text1.Text = Text1.Text & bytesTotal & vbCrLf
Text1.SelStart = Len(Text1.Text)
Winsock2.SendData bMsg

End Sub

Private Sub Winsock2_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)

Text1.Text = Text1.Text & "Winsock2出错!" & vbCrLf

End Sub

Private Sub Winsock2_SendComplete()

Text1.Text = Text1.Text & "向Sphere发送了数据.." & vbCrLf

End Sub

Private Sub Winsock2_SendProgress(ByVal bytesSent As Long, ByVal bytesRemaining As Long)

Text1.Text = Text1.Text & "向Sphere发送了" & bytesSent & "数据.." & vbCrLf

End Sub


上一篇:2000年扣篮大赛

下一篇:黎巴嫩和法国