1. 各種パラメータを受け取る
1-1. strBrowserName as String
1-2. strContentOfWb as String
2. strBrowserNameに格納されている名前を持つWebBrowserに表示されている内容を、タグを含めて、strContentOfWbに代入する
3. strContentOfWbを返す
関数で取得に成功の場合はリターン値にTrue を返します。strContentOfWb変数にタグ付きの内容をセット
関数で取得に失敗の場合はリターン値にFalseを返します。strContentOfWb変数は空です。
Public Function Aaa(ByVal strBrowserName As String, ByRef strContentOfWb As String) As Boolean Dim AllCtrl As Control() = GetAllControls(Me) Dim wb As WebBrowser = Nothing strContentOfWb = "" For Each c As Control In AllCtrl If c.GetType().Equals(GetType(WebBrowser)) Then If c.Name = strBrowserName Then wb = c Exit For End If End If Next If wb Is Nothing Then Return False End If strContentOfWb = wb.DocumentText Return True End Function Private Function GetAllControls(ByVal top As Control) As Control() 'http://www.atmarkit.co.jp/fdotnet/dotnettips/224controls/controls.html Dim buf As ArrayList = New ArrayList For Each c As Control In top.Controls buf.Add(c) buf.AddRange(GetAllControls(c)) Next Return CType(buf.ToArray(GetType(Control)), Control()) End Function
※なお、WebBrowserのコントロールはデザインでフォームに貼り付けているものと仮定しています。
コメント(0件)