【VB开源代码栏目提醒】:网学会员为广大网友收集整理了,tr1.frm,希望对大家有所帮助!
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 2655
ClientLeft = 60
ClientTop = 345
ClientWidth = 3705
LinkTopic = "Form1"
ScaleHeight = 2655
ScaleWidth = 3705
StartUpPosition = 3 'Windows Default
Begin MSComDlg.CommonDialog ffile
Left = 2280
Top = 720
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin MSWinsockLib.Winsock t
Left = 840
Top = 720
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.CommandButton Command3
Caption = "打印"
Height = 375
Left = 2520
TabIndex = 3
Top = 2160
Width = 855
End
Begin VB.CommandButton Command2
Caption = "清除"
Height = 375
Left = 1440
TabIndex = 2
Top = 2160
Width = 735
End
Begin VB.CommandButton Command1
Caption = "保存"
Height = 375
Left = 240
TabIndex = 1
Top = 2160
Width = 735
End
Begin VB.TextBox Text1
Height = 1335
Left = 240
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 0
Top = 120
Width = 3255
End
Begin
VB.Label Label1
Caption = "服务器端"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1200
TabIndex = 4
Top = 1680
Width = 1335
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'以下是服务器
程序 Private Sub Command1_Click()
'把接收到的文件保存
ffile.ShowSave '打开文件对话框保存文件
Open ffile.filename For Output As #1 '打开文件为1#用于写
Print #1, Text1.Text, Len(Text1.Text) '把文本内容和记录长度写入
Close #1 '关闭文件
End Sub
Private Sub Command2_Click()
'清除文本
Text1.Text = ""
End Sub
Private Sub Command3_Click()
'把接收到的文件打印
Printer.Print Text1.Text
Printer.EndDoc
End Sub
Private Sub Form_Load()
ffile.Filter = "html files|*.htm|text files|*.txt all file|*.*"
t.LocalPort = 100 '用于侦听本地端口
t.Listen '把服务器设置为侦听模式
Form2.Show '打开客户窗口
End Sub
Private Sub t_ConnectionRequest(ByVal requestID As Long)
'检查控件状态是否关闭,若不是,在接受新的连接前先关闭
If t.State <> 0 Then t.Close
t.Accept requestID '接受具有requestID参数的连接
End Sub
Private Sub t_DataArrival(ByVal bytesTotal As Long)
'接收客户机发耒数据
Dim strdata As String
t.GetData strdata '接收客户机发耒数据放入strdata
Text1.Text = strdata '把数据送到文本显示
End Sub