想编写一个东西 编到一半了 下边是源码
Option Explicit
Private FormOldWidth As Long
Private FormOldHeight As Long
Public Sub ResizeInit(FormName As Form)
Dim Obj As Control
FormOldWidth = FormName.ScaleWidth
FormOldHeight = FormName.ScaleHeight
On Error Resume Next
For Each Obj In FormName
If TypeOf Obj Is ComboBox Then
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.FontSize & " "
ElseIf TypeOf Obj Is CommandButton Then
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " " & Obj.FontSize & " "
ElseIf TypeOf Obj Is Line Then
Obj.Tag = Obj.X1 & " " & Obj.X2 & " " & Obj.Y1 & " " & Obj.Y2 & " " & Obj.BorderWidth & " "
Else
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " " End If
Next Obj
On Error GoTo 0
End Sub
Public Sub ResizeForm(FormName As Form)
Dim Pos(4) As Double
Dim i As Long, TempPos As Long, StartPos As Long
Dim Obj As Control
Dim ScaleX As Double, ScaleY As Double
ScaleX = FormName.ScaleWidth / FormOldWidth
ScaleY = FormName.ScaleHeight / FormOldHeight
On Error Resume Next
For Each Obj In FormName
StartPos = 1
For i = 0 To 5
TempPos = InStr(StartPos, Obj.Tag, " ", vbTextCompare)
If TempPos > 0 Then
Pos(i) = Mid(Obj.Tag, StartPos, TempPos - StartPos)
StartPos = TempPos + 1
Else
Pos(i) = 0
End If
Next i
If TypeOf Obj Is ComboBox Then
Obj.FontSize = Pos(3) * ScaleY
Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX
ElseIf TypeOf Obj Is CommandButton Then
Obj.FontSize = Pos(4) * ScaleY
Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
ElseIf TypeOf Obj Is Line Then
Obj.X1 = Pos(0) * ScaleX
Obj.X2 = (Pos(1) - Pos(0)) * ScaleX + Obj.X1
Obj.Y1 = Pos(2) * ScaleY
Obj.Y2 = (Pos(3) - Pos(2)) * ScaleY + Obj.Y1
Obj.BorderWidth = Pos(4) * Sqr(ScaleX * ScaleX + ScaleY * ScaleY)
Else
Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
End If
Next Obj
On Error GoTo 0
End Sub
Private Sub Form_Initialize()
Call ResizeInit(Me)
End Sub
Private Sub Form_Resize()
Call ResizeForm(Me)
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate "www.baidu.com"
End Sub
Private Sub com_Click()
WebBrowser1.Navigate Text1.Text
End SubPrivate Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
WebBrowser1.Navigate2 WebBrowser1.Document.activeElement.href
End Sub
Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
Lab1.Caption = Text
End Sub
希望高手改写成 打开网页之后自动在搜索框里输入文字并搜索
最好是打开TXT文档里的文件 嘿嘿
Option Explicit
Private FormOldWidth As Long
Private FormOldHeight As Long
Public Sub ResizeInit(FormName As Form)
Dim Obj As Control
FormOldWidth = FormName.ScaleWidth
FormOldHeight = FormName.ScaleHeight
On Error Resume Next
For Each Obj In FormName
If TypeOf Obj Is ComboBox Then
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.FontSize & " "
ElseIf TypeOf Obj Is CommandButton Then
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " " & Obj.FontSize & " "
ElseIf TypeOf Obj Is Line Then
Obj.Tag = Obj.X1 & " " & Obj.X2 & " " & Obj.Y1 & " " & Obj.Y2 & " " & Obj.BorderWidth & " "
Else
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " " End If
Next Obj
On Error GoTo 0
End Sub
Public Sub ResizeForm(FormName As Form)
Dim Pos(4) As Double
Dim i As Long, TempPos As Long, StartPos As Long
Dim Obj As Control
Dim ScaleX As Double, ScaleY As Double
ScaleX = FormName.ScaleWidth / FormOldWidth
ScaleY = FormName.ScaleHeight / FormOldHeight
On Error Resume Next
For Each Obj In FormName
StartPos = 1
For i = 0 To 5
TempPos = InStr(StartPos, Obj.Tag, " ", vbTextCompare)
If TempPos > 0 Then
Pos(i) = Mid(Obj.Tag, StartPos, TempPos - StartPos)
StartPos = TempPos + 1
Else
Pos(i) = 0
End If
Next i
If TypeOf Obj Is ComboBox Then
Obj.FontSize = Pos(3) * ScaleY
Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX
ElseIf TypeOf Obj Is CommandButton Then
Obj.FontSize = Pos(4) * ScaleY
Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
ElseIf TypeOf Obj Is Line Then
Obj.X1 = Pos(0) * ScaleX
Obj.X2 = (Pos(1) - Pos(0)) * ScaleX + Obj.X1
Obj.Y1 = Pos(2) * ScaleY
Obj.Y2 = (Pos(3) - Pos(2)) * ScaleY + Obj.Y1
Obj.BorderWidth = Pos(4) * Sqr(ScaleX * ScaleX + ScaleY * ScaleY)
Else
Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
End If
Next Obj
On Error GoTo 0
End Sub
Private Sub Form_Initialize()
Call ResizeInit(Me)
End Sub
Private Sub Form_Resize()
Call ResizeForm(Me)
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate "www.baidu.com"
End Sub
Private Sub com_Click()
WebBrowser1.Navigate Text1.Text
End SubPrivate Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
WebBrowser1.Navigate2 WebBrowser1.Document.activeElement.href
End Sub
Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
Lab1.Caption = Text
End Sub
希望高手改写成 打开网页之后自动在搜索框里输入文字并搜索
最好是打开TXT文档里的文件 嘿嘿
http://www.baidu.com/s?tn=5igb_dg&wd=关键字
Open "c:\xx.txt" For Input As #1
s = StrConv(InputB$(LOF(1), #1), vbUnicode)
Close #1
msgbox s