紧急,高手来赚分

来源:百度知道 编辑:UC知道 时间:2024/04/29 02:10:02
VB里用 Webbrowser打开一个网页,怎么向里面发送文字,一般的我知道,可是遇到这种文本框,不知道怎么用代码自动输入了

网页部分代码
<td><input type="text" id="subject" name="subject" size="65" value="" tabindex="4" /></td>
</tr>

<tr>
<th valign="top"><label for="pm_textarea">内容</label>
<div id="smilieslist"></div>
<script type="text/javascript">ajaxget('post.php?action=smilies', 'smilieslist');</script>
</th>
<td><textarea id="pm_textarea" class="autosave" rows="15" cols="10" name="message" style="width: 95%;" onKeyDown="ctlent(event);" tabindex="5">
</textarea>

类似 百--度 空间里面编辑文章时的 内容那个框,怎么用代码写进去
badboystone注意,标题的那个我会,我是问内容那块

先在VB中引用 Microsoft HTML Object Library

Private Sub Command1_Click()
Dim oDoc As HTMLDocument
Dim oElement As Object
Set oDoc = WebBrowser1.Document

Set oElement = oDoc.getElementsByName("message")
oElement(0).Value = "内容"
End Sub

这是修改信息内容的,同理,要修改标题就把
Set oElement = oDoc.getElementsByName("message")
中的message改成标题控件的名字:subject

Dim vDoc, vTag
Dim i As Integer

Set vDoc = Form2.WebBrowser1.Document
For i = 0 To vDoc.All.length - 1
If UCase(vDoc.All(i).tagName) = "INPUT" Then
Set vTag = vDoc.All(i)
If vTag.Type = "text" Then
Select Case vTag.Name
Case "subject"
vTag.Value = "标题内容"
End Select
End If
End If
Ne