300分求:做一个VB程序读远程服务器端ASP的response.write"..."的信息

非常急用。感谢DX帮忙,加到三百分.我的目的是做一个VB读取ASP返回信息的工具。

远程服务器(假设是http://127.0.0.1/)只有一个ASP文件如下:

login.asp

<%
if request.querystring("userid")="ja001" and request.querystring("password")="ja002" then'如果用户名和密码正确
response.write("登录成功!")
response.write(date())
else
response.write("登录失败!")
end if
%>

希望做到如下:
一、用VB6做一个小软件,打开时显示登录界面(界面较小),只要有“用户名”框和“密码”框以及“登录”按钮就行。
二、在此登录界面输入用户名ja001和密码ja002后,点击登录,用VB保存会话信息,并同时读取远程http://www.aa.com/上的login.asp的返回信息。
三、如果远程返回的是“登录失败”字符串,则提示登录失败并返回登录界面重新登录。
四、如果远程返回的是“登录成功”字符串,跳转到软件界面(较大的界面)。
五、在软件界面每隔1秒读一次login.asp,实时显示时间信息。

非常感谢。
我刚学VB,可以说不懂.请写出VB(最好提VB6)编的可正常编译的全部源代码,注意事项等.再次表示感谢.

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

Public Sub New()
MyBase.New()

'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()

'在 InitializeComponent() 调用之后添加任何初始化

End Sub

'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer

'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents txtUserName As System.Windows.Forms.TextBox
Friend WithEvents btnLogin As System.Windows.Forms.Button
Friend WithEvents btnCancle As System.Windows.Forms.Button
Friend WithEvents txtPassWord As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.btnLogin = New System.Windows.Forms.Button
Me.btnCancle = New System.Windows.Forms.Button
Me.txtUserName = New System.Windows.Forms.TextBox
Me.txtPassWord = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(24, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(48, 17)
Me.Label1.TabIndex = 0
Me.Label1.Text = "用户名:"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(24, 48)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(35, 17)
Me.Label2.TabIndex = 1
Me.Label2.Text = "密码:"
'
'btnLogin
'
Me.btnLogin.Location = New System.Drawing.Point(32, 88)
Me.btnLogin.Name = "btnLogin"
Me.btnLogin.TabIndex = 2
Me.btnLogin.Text = "登录"
'
'btnCancle
'
Me.btnCancle.Location = New System.Drawing.Point(136, 88)
Me.btnCancle.Name = "btnCancle"
Me.btnCancle.TabIndex = 3
Me.btnCancle.Text = "取消"
'
'txtUserName
'
Me.txtUserName.Location = New System.Drawing.Point(80, 16)
Me.txtUserName.Name = "txtUserName"
Me.txtUserName.TabIndex = 4
Me.txtUserName.Text = ""
'
'txtPassWord
'
Me.txtPassWord.Location = New System.Drawing.Point(80, 40)
Me.txtPassWord.Name = "txtPassWord"
Me.txtPassWord.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.txtPassWord.TabIndex = 5
Me.txtPassWord.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(240, 127)
Me.Controls.Add(Me.txtPassWord)
Me.Controls.Add(Me.txtUserName)
Me.Controls.Add(Me.btnCancle)
Me.Controls.Add(Me.btnLogin)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.Text = "登录"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub btnCancle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancle.Click
Me.Close()
End Sub

Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If Me.txtUserName.Text.Trim.Length = 0 Or Me.txtPassWord.Text.Trim.Length = 0 Then
MsgBox("请输入用户名或密码")
Exit Sub
End If
Dim conString As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=D:\Inetpub\wwwroot\WebApplication1\Database\Test.mdb"
Dim conn As New OleDb.OleDbConnection(conString)
Dim comm As New OleDb.OleDbCommand("SELECT UserName, PassWord FROM UserInfo WHERE UserName = '" & Me.txtUserName.Text & "'", conn)
Try
conn.Open()
Dim dr As OleDb.OleDbDataReader = comm.ExecuteReader()
If dr.HasRows Then
dr.Read()
If dr.Item("PassWord").ToString = Me.txtPassWord.Text Then
MsgBox("登录成功")
Else
MsgBox("登录失败")
End If
End If
dr.Close()
Catch ex As Exception
MsgBox(ex.ToString)
Finally
If conn.State = ConnectionState.Open Then conn.Close()
conn.Dispose()
comm.Dispose()
End Try
End Sub
End Class
http://www.80diy.com/home/20051101/10/4363173.html
或参考
http://zhidao.baidu.com/question/8176586.html
温馨提示:答案为网友推荐,仅供参考
第1个回答  2007-11-15
很简单,使用xml-http访问login.asp,让login.asp生成XML或标准的xhtml格式,分析结构

如果想掌握的更好可以学习webservice(SOAP),.NETL里的,但VB6通过XML-HTTP同样可以访问webservice
如果不注重返回数据结构,直接写最简单的XML分析就可以了

使用inet或webbrowser不能很好的控制

LOGIN.ASP
改为
'-----------------下行开始,定义XML必须为顶行,不能有空,这行不要<?xml前边不能换行,不能有空格
<%Response.ContentType = "text/xml"%><?xml version="1.0" encoding="gb2312"?>
<html>
<body>
<%
if request.querystring("userid")="ja001" and request.querystring("password")="ja002" then'如果用户名和密码正确
response.write("登录成功!")
response.write(date())
else
response.write("登录失败!")
end if
%>
if request.querystring("userid")="ja001" and request.querystring("password")="ja002" response.write("<des>登录成功!</des>")
response.write("<date>" & date & "</date>")
else
response.write("<des>登录失败!</des>")
response.write("<date />")
end if
%>
</body>
</html>
第2个回答  2007-11-15
Private Sub Command1_Click()
Inet1.Execute "http://127.0.0.1/login.asp", "POST", "userid=" & Text1 & "&password=" & Text2
End Sub

Private Sub Form_Load()
Text1 = ""
Text2 = ""
Timer1.Interval = 1000
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case 12
isGetData = Inet1.GetChunk(1024)
If isGetData = "登录成功!" Then
'跳转到大的程序界面
Unload Me
ElseIf isGetData = "登录失败!" Then
Text1 = ""
Text2 = ""
Command1_Click
End If
MsgBox isGetData
End Select
End Sub

Private Sub Timer1_Timer()
Label1 = Date$ & " " & Time$
End Sub
第3个回答  2007-11-15
我现在没上q ,所以帖上代码 ..或者你留个邮箱把
qq 现在要去装 ,我在别人家 不太好意思 去动人家的电脑

Private Sub Command1_Click()
Inet1.Execute "POST", Text1, "userid=" & Text2 & "&password=" & Text3
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
If State = 12 Then
str1 = Inet1.GetChunk(0)
If str1 = "登陆成功" Then
Form2.Show
ElseIf str1 = "登陆失败" Then
End If
End If
End Sub本回答被提问者采纳
第4个回答  2007-11-15
已经发送,请查收