vb中自动填写表单WebBrowser的有关问题
vb中自动填写表单WebBrowser的问题
相关网页代码:
用户名: <input name= 'UserName ' type= 'text ' id= 'UserName '>
密 码: <input name= 'UserPassword ' type= 'password ' id= 'Password '>
验证码: </td> <td height= '25 '> <input name= 'CheckCode ' type= 'text ' id= 'CheckCode ' size= '6 ' maxlength= '6 '> <a href= 'javascript:refreshimg() ' title= '看不清楚,换个图片 '> <img id= 'checkcode ' src= 'inc/checkcode.asp ' style= 'border: 1px solid #ffffff '> </a> </td>
<input name= 'Login ' type= 'submit ' id= 'Login ' value= ' 登 录 '>
<script language=javascript>
function refreshimg(){document.all.checkcode.src= 'inc/checkcode.asp ';}
function CheckLoginForm(){
if(document.UserLogin.UserName.value== ' '){
alert( '请输入用户名! ');
document.UserLogin.UserName.focus();
return false;
}
if(document.UserLogin.Password.value == ' '){
alert( '请输入密码! ');
document.UserLogin.Password.focus();
return false;
}
if(document.UserLogin.CheckCode.value == ' '){
alert( '请输入验证码! ');
document.UserLogin.CheckCode.focus();
return false;
}
}
</script>
我的VB代码:
Private Sub kxedu_DocumentComplete(ByVal pDisp As Object, URL As Variant)
web.Document.Forms(0).UserLogin.UserName.Value = "msn2005 "
web.Document.Forms(0).UserLogin.Password.Value = "724864 "
web.document.Forms(0).UserLogin.CheckCode.Value=???
web.Document.Forms(0).Login.Click
End Sub
我这种方法简直没用,后来参考其它资料,改为如下:
Dim vDoc, vTag
Dim i As Integer
Dim h As Integer
Set vDoc = kxedu.Document
For i = 0 To vDoc.All.length - 1
Set vTag = vDoc.All(i)
相关网页代码:
用户名: <input name= 'UserName ' type= 'text ' id= 'UserName '>
密 码: <input name= 'UserPassword ' type= 'password ' id= 'Password '>
验证码: </td> <td height= '25 '> <input name= 'CheckCode ' type= 'text ' id= 'CheckCode ' size= '6 ' maxlength= '6 '> <a href= 'javascript:refreshimg() ' title= '看不清楚,换个图片 '> <img id= 'checkcode ' src= 'inc/checkcode.asp ' style= 'border: 1px solid #ffffff '> </a> </td>
<input name= 'Login ' type= 'submit ' id= 'Login ' value= ' 登 录 '>
<script language=javascript>
function refreshimg(){document.all.checkcode.src= 'inc/checkcode.asp ';}
function CheckLoginForm(){
if(document.UserLogin.UserName.value== ' '){
alert( '请输入用户名! ');
document.UserLogin.UserName.focus();
return false;
}
if(document.UserLogin.Password.value == ' '){
alert( '请输入密码! ');
document.UserLogin.Password.focus();
return false;
}
if(document.UserLogin.CheckCode.value == ' '){
alert( '请输入验证码! ');
document.UserLogin.CheckCode.focus();
return false;
}
}
</script>
我的VB代码:
Private Sub kxedu_DocumentComplete(ByVal pDisp As Object, URL As Variant)
web.Document.Forms(0).UserLogin.UserName.Value = "msn2005 "
web.Document.Forms(0).UserLogin.Password.Value = "724864 "
web.document.Forms(0).UserLogin.CheckCode.Value=???
web.Document.Forms(0).Login.Click
End Sub
我这种方法简直没用,后来参考其它资料,改为如下:
Dim vDoc, vTag
Dim i As Integer
Dim h As Integer
Set vDoc = kxedu.Document
For i = 0 To vDoc.All.length - 1
Set vTag = vDoc.All(i)