vb源碼大全
⑴ 用vb獲取任一網頁源代碼,要完整的!!!,可以用webbrowser控制項
'你把下面的代碼保存為Form1.frm,然後雙擊打開該文件,運行後按提示即可看到結果。
'呵呵,夠詳細了,再不會我也沒辦法了。
'====文件Form1.frm====
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5265
ClientLeft = 60
ClientTop = 450
ClientWidth = 9000
LinkTopic = "Form1"
ScaleHeight = 5265
ScaleWidth = 9000
StartUpPosition = 3 '窗口預設
Begin VB.TextBox Text2
Height = 3735
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 2
Top = 480
Width = 8655
End
Begin VB.TextBox Text1
Height = 270
Left = 2040
TabIndex = 1
Text = "我的家"
Top = 120
Width = 4095
End
Begin VB.CommandButton Command1
Caption = "獲取HTML源碼"
Height = 615
Left = 3480
TabIndex = 0
Top = 4440
Width = 1575
End
Begin VB.Label Label2
Caption = "注意:獲取源碼之前必須先用IE打開網址,然後輸入窗口標題關鍵字。如www.51.com的標題關鍵字是:我的家"
Height = 615
Left = 240
TabIndex = 4
Top = 4440
Width = 3135
End
Begin VB.Label Label1
Caption = "請輸入IE窗口標題:"
Height = 255
Left = 120
TabIndex = 3
Top = 120
Width = 1815
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Function GetIeHtml(IeTitle As String) As String
Dim oShellApp: Set oShellApp = CreateObject("Shell.Application")
Dim oShellAppWindows: Set oShellAppWindows = oShellApp.Windows
Dim owin
'獲取彈出的IE窗口
For Each owin In oShellAppWindows '獲取彈出的IE窗口
If LCase(TypeName(owin.Document)) = "htmldocument" And _
InStr(1, owin.LocationName, IeTitle, vbTextCompare) > 0 Then '如果找到符合條件的IE窗口
GetIeHtml = owin.Document.activeElement.Document.documentElement.innerHTML '此句可獲得完整html代碼
GoTo Mend '退出
End If
Next
Mend:
Set oShellAppWindows = Nothing
Set oShellApp = Nothing
Set owin = Nothing
End Function
Private Sub Command1_Click()
Dim S As String
S = GetIeHtml(Text1.Text) '表示獲得標題含有"我的家"的html代碼
Text2.Text = S
End Sub
Private Sub Form_Load()
'Shell "explorer.exe ""http://www.51.com/""", vbNormalNoFocus
End Sub
⑵ vb游戲代碼大全vb小游戲源代碼
關於vb游戲代碼大全,vb小游戲源代碼這個很多人還不知道,今天來為大家解答以上的問題,現在讓我們一起來看看吧!
1、Rem 窗體創建三個單選框按鈕,OptionOption2、Option3 Private Sub Form_Activate() Option1.Caption = "石頭" Option2.Caption = "剪刀" Option3.Caption = "布" Option1.Value = False Option2.Value = False Option3.Value = False End Sub Private Sub Option1_Click() Randomize Select Case Int(3 * Rnd) Case 0: MsgBox "對方也出石頭!繼續!" Case 1: MsgBox "哈哈!你贏了!對方出的是剪刀!獎勵你一個蘋果!" Case 2: MsgBox "你輸了!對方出的是布哦!不好意思,蘋果給對方了哈!" End Select Option1.Value = False End Sub Private Sub Option2_Click() Randomize Select Case Int(3 * Rnd) Case 0: MsgBox "你輸了!對方出的是石頭哦!不好意思。
2、蘋果給對方了哈!" Case 1: MsgBox "對方也出剪刀!繼續!" Case 2: MsgBox "哈哈!你贏了!對方出的是布!獎勵你一個蘋果!" End Select Option2.Value = False End Sub Private Sub Option3_Click() Randomize Select Case Int(3 * Rnd) Case 0: MsgBox "哈哈!你贏了!對方出的是石頭!獎勵你一個蘋果!" Case 1: MsgBox "你輸了!對方出的是剪刀哦!不好意思,蘋果給對方了哈!" Case 2: MsgBox "對方也出布!繼續!" End Select Option3.Value = False End Sub。