當前位置:首頁 » 操作系統 » vb源碼大全

vb源碼大全

發布時間: 2025-05-06 16:26:41

⑴ 用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。

熱點內容
java名稱 發布:2025-05-06 19:15:19 瀏覽:980
資料庫是如何設計的 發布:2025-05-06 19:13:10 瀏覽:645
用主機搭建方舟伺服器 發布:2025-05-06 19:12:58 瀏覽:519
怎麼避免坐滴滴蘋果比安卓貴 發布:2025-05-06 19:04:53 瀏覽:729
新房凈水器怎麼配置 發布:2025-05-06 19:03:19 瀏覽:975
java多個線程 發布:2025-05-06 18:53:16 瀏覽:291
查看app伺服器地址 發布:2025-05-06 18:35:18 瀏覽:374
linux搭建java環境 發布:2025-05-06 18:30:18 瀏覽:477
光遇別人可以看見裝扮的腳本 發布:2025-05-06 18:19:20 瀏覽:144
搭建應用程序伺服器 發布:2025-05-06 17:57:59 瀏覽:136