掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
無事ビルドするには? (ID:125704)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
環境はVB.net 2003です。 http://www.gotdotnet.com/japan/student/column/firststep/firststep19.aspx のサイトに載っているC#をVBに書き直しています。 自分なりに直したつもりですが、 最後のほうで Option Strict OnでStringからDoubleへの暗黙的な変換はできません というエラーがでてビルドができません。 本人はstringからstringへの書き込みをしてるつもりなんですがエラーが でるので無事ビルドするにはどこを直したいいか教えていただけませんか。 どこが悪いのかわからないので全ソース載せること失礼かと思いますが よろしくお願いします。 Option Strict On Imports System.Net Imports System.Text.RegularExpressions Imports System.Text Imports System.IO Private Sub downButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles downButton.Click Try Dim downloadurl As String = urlText.Text Dim filepath As String = filePathText.Text Dim downloaddirurl As String = downloadurl.Substring(0, downloaddirurl.LastIndexOf("/") + 1) Dim webClient As WebClient = New WebClient webClient.DownloadFile(downloadurl, "c:\\temp.html") 'c:\\temp.htmlの内容をcontentsに格納 Dim reader As StreamReader = File.OpenText("c:\\temp.html") Dim contents As String = reader.ReadToEnd() reader.Close() 'contentsからリンク情報のリストを抽出 Dim regex As Regex = New Regex("<a +href=('|"")[^('|"")]*('|"")*>") Dim matchcollection As MatchCollection = Regex.Matches(contents) '各リンク情報からURLを抽出し、ダウンロードする Dim i As Integer For i = 0 To matchcollection.Count Dim urlregex As Regex = New Regex("('|"")[^('|"")]*('|"")") Dim match As Match = urlregex.Match(matchcollection(i).Value) Dim url As String = match.Value.Substring(1, match.Value.Length - 2) If url.IndexOf("http://") <> 0 Then url = downloaddirurl + url '抽出されたリンク情報をテキストボックスに表示 urlListText.Text += url + "vbCrLf" 'ファイル名を取得 Dim filenamestart As Integer = url.LastIndexOf("/") + 1 Dim filenamelength As Integer = url.Length - filenamestart Dim filename As String = url.Substring(filenamestart, filenamelength) ’************** 'ダウンロード先ファイルパスを作成 Dim downloadpath As String = filepath + "\\" + "down"+filenamestart ’エラー発生箇所 ’*************** Try webClient.DownloadFile(url, downloadpath) Catch ex As Exception End Try End If Next Catch ex As Exception End Try End Sub
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.