Dim wc As New System.Net.WebClient() wc.DownloadFile("http://localhost/image.gif", "c:\test\1.gif") wc.Dispose()
vb.net ファイルをダウンロードして一気読み、保存する
Dim sr As StreamReader = New StreamReader("D:\test\hironimo.txt") txtRead.Text = sr.ReadToEnd sr.Close()
edge webview2でクッキー削除
CoreWebView2.CookieManager.DeleteAllCookies()
正規表現で最初のカンマのとこまで という設定
^([^,]+,){1}
[ ] 括弧内のいずれか 1 文字。 [^ ] 括弧内に含まれない 1 文字。 [^...] 角括弧に含まれる文字以外にマッチします。 {n} 直前のパターンを n 回繰り返し。
ブログやSEOなどの文章考える補佐してくれる「Rytr」
噂のGPT-3を使った自動文章作成ツール。
そんなに夢見るようなツールではないけど、プロットや下書き自動生成と考えれば結構すごいですね。
rytr.me
ExcelVBAでwindowsバージョン(10とか11とか) 返す
'OSのバージョンの数値を返す win10=10 win11=11 Function GetOsVersion() ' 取得結果を格納する変数を宣言 Dim lnArchitecture As Long Dim strCaption As String Dim strCSDVersion As String Dim strOSVersion As String ' 初期値を入れておく lnArchitecture = 32 strCaption = "" strCSDVersion = "Service Pack 0" On Error Resume Next Dim objOS As Object Dim i As Long ' Connect to WMI and obtain instances of Win32_OperatingSystem For Each objOS In GetObject("winmgmts:").InstancesOf("Win32_OperatingSystem") ' アーキテクチャの取得 On Error GoTo OSArchitectureNoSupport If InStr(1, CStr(objOS.OSArchitecture), "64", vbBinaryCompare) <> 0 Then lnArchitecture = 64 End If OSArchitectureNoSupport: On Error Resume Next ' キャプションを取得 For i = 1 To Len(objOS.Caption) Dim strTemp As String: strTemp = Strings.Mid$(objOS.Caption, i, 1) If AscW(strTemp) = &H2122 Then strCaption = strCaption & " TM" ElseIf AscW(strTemp) = &H24C7 Or AscW(strTemp) = &HAE Then strCaption = strCaption & "(R)" Else strCaption = strCaption & strTemp End If Next i ' SPを取得 strCSDVersion = objOS.CSDVersion ' Versionを取得 strOSVersion = objOS.Versionn Next GetOsVersion = FirstVal(strCaption) Set objOS = Nothing End Function '文字列の中から最初に見つかった数値をval()で変換して返す Function FirstVal(str As String) As Integer Dim buf As String, RE, reMatch, reValue Set RE = CreateObject("VBScript.RegExp") buf = str With RE .Pattern = "\d+" .Global = True Set reMatch = .Execute(buf) If reMatch.count > 0 Then For Each reValue In reMatch FirstVal = Val(reValue) Exit For Next reValue End If End With Set RE = Nothing End Function
GoogleAnalyticsで月ごとのデータを確認する
月(年間)が2つあって、?にカーソル合わせて「 YYYYMM形式です」というほう。
もう一つのほうは、年を意識しないで完全に月別に集計するパターンです。
webview2でファイルのダウンロード完了を待つ方法
webページのダウンロード待ちではなくて、PCにファイルをダウンロードするときの処理。
DevTools Protocolを使う。
ダウンロードを始めてから
m_downloadState をみてcompletedかcanceledかになるまで待つようにすればOK
Private m_downloadState As String ... Private Sub CoreWebView2_DevToolsProtocolEventReceived(sender As Object, e As CoreWebView2DevToolsProtocolEventReceivedEventArgs) If InStr(e.ParameterObjectAsJson, """state"":""completed""") <> 0 Then m_downloadState = "completed" ElseIf InStr(e.ParameterObjectAsJson, """state"":""inProgress""") <> 0 Then m_downloadState = "inProgress" ElseIf InStr(e.ParameterObjectAsJson, """state"":""canceled""") <> 0 Then m_downloadState = "canceled" Else m_downloadState = "" End If End Sub ... Await FormE.view2.CoreWebView2.CallDevToolsProtocolMethodAsync("Page.enable", "{}") AddHandler FormE.view2.CoreWebView2.GetDevToolsProtocolEventReceiver("Page.downloadProgress").DevToolsProtocolEventReceived, AddressOf CoreWebView2_DevToolsProtocolEventReceived