Private Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button.Click Dim PrefCode As New List(Of Integer) Dim Text As String = Me.TextBox.Text If Text <> String.Empty Then 'まず県名で検索 For Each c As Integer() In (From p As Region In Me.Pref Where p.Name Like "*" & Text & "*" Or Text Like p.Name & "*" Select p.Code).ToArray PrefCode.AddRange(c) Next '県名で一致しなければ地方名で検索 If PrefCode.Count = 0 Then For Each c As Integer() In (From p As Region In Me.Regions Where p.Name Like "*" & Text & "*" Or Text Like p.Name & "*" Select p.Code).ToArray PrefCode.AddRange(c) Next End If End If Using wc As New WebClient() Dim Map As Byte() = wc.DownloadData(CreateUrl(PrefCode.ToArray)) Dim ImgConv As New ImageConverter Me.PictureBox.Image = DirectCast(ImgConv.ConvertFrom(Map), Image) End Using End Sub Private Function CreateUrl(ByVal PrefCode() As Integer) As String Dim Url As String = "https://chart.googleapis.com/chart?" & "cht=map:fixed=24,122,46,149" & "&chf=bg,s,99CCFF" & "&chs=600x500" Dim chldLst As New List(Of String) Dim chcoLst As New List(Of String) For Each p As Region In Pref For Each c As Integer In p.Code chldLst.Add("JP-" & c.ToString("00")) If PrefCode.Contains(c) Then chcoLst.Add("FFFF00") '黄色 Else chcoLst.Add("696969") '灰色 End If Next Next Dim chld As String = "&chld=" & String.Join("|", chldLst) Dim chco As String = "&chco=C0C0C0|" & String.Join("|", chcoLst) Return Url & chld & chco End Function Private Sub TextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox.KeyPress If e.KeyChar = ChrW(Keys.Enter) Then Me.Button.PerformClick() e.Handled = True End If End Sub End Class