用VB发送成绩

来源:百度知道 编辑:UC知道 时间:2024/05/12 15:27:16
我用VB 6.0做了个小游戏,并在窗体放了一个combobox控件和一个TEXT控件,combobox上面写的是姓名得分,另一个TEXT上面写的是游戏得分,现在我想用一个按扭,按下按扭后那姓名和成绩就会发送到我的邮箱,或我的个人网站上(支持ASP和PHP),该怎么弄呢,我刚学的VB很菜!
请高手指点! 本人万分感激

假设你的服务器127.0.0.1,asp文件为 index.asp

1.
加入winsock控件,步骤:工程->部件,选择Microsoft WinSock Control 6.0(SP6),确定。Winsok就加到工具箱里了,
Form上添加一个Winsock

2.定义两个公用变量,userName,userScore 存放姓名和成绩

3.发送代码如下

Dim userName As String
Dim userScore As String

Private Sub SendStr() '为姓名成绩赋初值
userName = "wangxin"
userScore = "88"
Winsock1.RemoteHost = "127.0.0.1"
Winsock1.RemotePort = 80
Winsock1.Connect
End Sub

Private Sub Winsock1_Connect()
Dim strCommand As String
Dim content As String

content = "name=" & userName & "&score=" & userScore

strCommand = "POST /index.asp HTTP/1.1" + vbCrLf
strCommand = strCommand + "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*" + vbCrLf
strCommand = strCommand + "Accept-Language: zh-cn" + vbCrLf