VB 版 (精华区)

发信人: JW (jw), 信区: VB
标  题: 简单的互联网传送文件
发信站: 哈工大紫丁香 (2001年08月31日21:54:57 星期五), 站内信件

本源程序用于在互联网上进行C/S结构的文件传送!方法土了点,不过功能还算可以
服务器端:
'注:窗体上还有一个媒体播放控件,请注意,还需要有一个webbroser控件。和四个输
入IP地址的text框。
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" 
Then
MsgBox "IP地址有错误,请检查"
End If
MediaPlayer1.Visible = True
MediaPlayer1.Width = Form1.Width
MediaPlayer1.Height = Form1.Height
MediaPlayer1.FileName = "c:\me\globe.avi"
MediaPlayer1.Play
Me.Caption = "正在连接客户端计算机"
Dim a As String
a = "\\" & Text1.Text & "." & Text2.Text & "." & Text3.Text & "." & Text4.Te
xt & "\"
WebBrowser1.Navigate a
Exit Sub
End Sub
Private Sub Text1_Change()
If Len(Text1.Text) >= 3 Then Text2.SetFocus
End Sub
Private Sub Text2_Change()
If Len(Text2.Text) >= 3 Then Text3.SetFocus
End Sub
Private Sub Text3_Change()
If Len(Text3.Text) >= 3 Then Text4.SetFocus
End Sub
Private Sub Timer1_Timer()
Static st As Integer
st = st + 1
If st > 18 And MediaPlayer1.Visible = False Then MediaPlayer1.FileName = ""
End Sub
Private Sub WebBrowser1_DownloadBegin()
On Error GoTo Myerror
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" 
Then Exit Sub
Me.Caption = "连接客户端"
Exit Sub
Myerror:
x = MsgBox("连接失败", vbAbortRetryIgnore + vbExclamation, "警告")
If x = vbabor Then
Command1_Click
ElseIf x = vbRetry Then
Command1_Click
Else
Me.Caption = "连接失败,请检查网络"
Exit Sub
End If
End Sub
Private Sub WebBrowser1_DownloadComplete()
Me.Caption = "服务端"
'MediaPlayer1.FileName = ""
MediaPlayer1.Visible = False
End Sub
客户机端:
'注:客户机只需把服务器需要的数据文件所在的文件夹共享,然后在窗体上添加一个w
inscok控件即可。
Private Sub Form_Load()
me.Caption = Winsock1.LocalIP
End Sub

--
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.170.186]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.137毫秒