{"id":2735,"date":"2009-10-07T13:48:27","date_gmt":"2009-10-07T04:48:27","guid":{"rendered":"http:\/\/www.ekbt.net\/blog\/?p=2735"},"modified":"2024-05-24T12:07:47","modified_gmt":"2024-05-24T03:07:47","slug":"%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e8%aa%ad%e3%81%bf%e6%9b%b8%e3%81%8d","status":"publish","type":"post","link":"https:\/\/ekbt.info\/?p=2735","title":{"rendered":"\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u66f8\u304d"},"content":{"rendered":"\n<p>Read\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u3093\u3067ListBox\u306b\u8868\u793a\u3057\u307e\u3059\u3002\u307e\u305f\u3001\u30d4\u30af\u30c1\u30e3\u30dc\u30c3\u30af\u30b9\u306b\u3082\u8868\u793a\u3057\u307e\u3059\u3002<br>Write\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001ListBox\u306e\u5185\u5bb9\u3092\u3001\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3078\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/ekbt.info\/wp-content\/uploads\/2020\/01\/20091007-vb000010.jpg\" alt=\"\" class=\"wp-image-15591\"\/><\/figure>\n\n\n\n<p>\u30d5\u30a9\u30fc\u30e0\uff11<\/p>\n\n\n\n<p>Public Class Form1<\/p>\n\n\n\n<p>\u30dc\u30bf\u30f3\uff11<\/p>\n\n\n\n<p><br> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<\/p>\n\n\n\n<p>\u2019\u30d5\u30a1\u30a4\u30ebIO\u7528\u306e\u5909\u6570\u7b49\u306e\u5ba3\u8a00<\/p>\n\n\n\n<p> Dim fname As String<br> Dim ret As DialogResult<br> Dim TextFile As IO.StreamReader<br> Dim Line As String<br> Dim cnt As Integer<\/p>\n\n\n\n<p>\u2019PictureBox1\u306eGraphics\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97<\/p>\n\n\n\n<p>Dim g As Graphics = PictureBox1.CreateGraphics()<br>Dim ystr As Integer<\/p>\n\n\n\n<p>\u2018\u30c0\u30a4\u30a2\u30ed\u30b0\u30dc\u30c3\u30af\u30b9\u306e\u521d\u671f\u8a2d\u5b9a<\/p>\n\n\n\n<p>With Me.OpenFileDialog1<br> \u3000.Title = \u201c\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\u201d<br> \u3000.CheckFileExists = True<br>\u3000 .RestoreDirectory = True<br> \u3000.Filter = \u201c\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb|<em>.txt;<\/em>.dat\u201d<br> \u3000.FileName = \u201ctest.txt\u201d<br> End With<\/p>\n\n\n\n<p>\u2018\u30c0\u30a4\u30a2\u30ed\u30b0\u30dc\u30c3\u30af\u30b9\u306e\u8868\u793a<\/p>\n\n\n\n<p>ret = Me.OpenFileDialog1.ShowDialog()<br>If ret = Windows.Forms.DialogResult.OK Then<br>\u3000fname = Me.OpenFileDialog1.FileName<br>Else<br>\u3000fname = \u201c\u201d<br>End If<br>If IO.File.Exists(fname) = False Then<br>\u3000MessageBox.Show(\u201c\u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002\u201d, \u201c\u901a\u77e5\u201d)<br>\u3000Exit Sub<br>End If<\/p>\n\n\n\n<p>\u2018\u30d5\u30a9\u30f3\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u4f5c\u6210<\/p>\n\n\n\n<p>Dim fnt As New Font(\u201cMS UI Gothic\u201d, 12)<br>Me.ListBox1.Items.Clear()<br>TextFile = New IO.StreamReader(fname, System.Text.Encoding.Default)<\/p>\n\n\n\n<p>cnt = 0<br>Do While True<br>\u3000Line = TextFile.ReadLine()<br>\u3000If Line = Nothing Then<br>\u3000\u3000Exit Do<br>\u3000End If<br>\u3000Me.ListBox1.Items.Add(Line)<br>\u3000cnt = cnt + 1<\/p>\n\n\n\n<p>\u2018\u6587\u5b57\u5217\u3092\u4f4d\u7f6e(0,0)\u3001\u9752\u8272\u3067\u8868\u793a<\/p>\n\n\n\n<p>\u3000g.DrawString(Line, fnt, Brushes.Blue, 0, ystr)<br>\u3000ystr = ystr + 20<br>Loop<br>TextFile.Close()<\/p>\n\n\n\n<p>\u2018\u30ea\u30bd\u30fc\u30b9\u3092\u958b\u653e\u3059\u308b<\/p>\n\n\n\n<p>fnt.Dispose()<br>g.Dispose()<br>Label2.Text = cnt.ToString<\/p>\n\n\n\n<p><br>End Sub<\/p>\n\n\n\n<p>\u30dc\u30bf\u30f3\uff12<\/p>\n\n\n\n<p>Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click<\/p>\n\n\n\n<p>Dim ret As DialogResult<br>Dim textfile As IO.StreamWriter<br>Dim i As Integer<br>Dim cnt As Integer<\/p>\n\n\n\n<p>\u3000cnt = Integer.Parse(Label2.Text)<\/p>\n\n\n\n<p>\u2018\u30c0\u30a4\u30a2\u30ed\u30b0\u30dc\u30c3\u30af\u30b9\u306e\u521d\u671f\u8a2d\u5b9a<\/p>\n\n\n\n<p>With Me.SaveFileDialog1<br> \u3000.RestoreDirectory = True<br>\u3000 .OverwritePrompt = True<br> \u3000.Filter = \u201c\u3059\u3079\u3066\u306e\u30d5\u30a1\u30a4\u30eb(<em>.<\/em>)|<em>.<\/em>|\u201d &amp; \u201c\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb(<em>.txt)|<\/em>.txt\u201d<br> \u3000.FileName = \u201cts.txt\u201d<br> End With<\/p>\n\n\n\n<p>\u2018\u30c0\u30a4\u30a2\u30ed\u30b0\u30dc\u30c3\u30af\u30b9\u306e\u8868\u793a<\/p>\n\n\n\n<p>ret = Me.SaveFileDialog1.ShowDialog<br>If ret = Windows.Forms.DialogResult.OK Then<br>\u3000Me.Label1.Text = \u3000\u3000Me.SaveFileDialog1.FileName<br><\/p>\n\n\n\n<p>\u2018\u73fe\u5728\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3067\u51fa\u529b<\/p>\n\n\n\n<p>\u2018textfile = New IO.StreamWriter(Me.Label1.Text, False, System.Text.Encoding.Default)<\/p>\n\n\n\n<p>\u2018\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3092Shift-JIS\u306b\u6307\u5b9a\u3059\u308b<\/p>\n\n\n\n<p>textfile = New IO.StreamWriter(Me.Label1.Text, False, System.Text.Encoding.GetEncoding(\\\u201dShift-JIS\\\u201d))<\/p>\n\n\n\n<p>For i = 1 To ListBox1.Items.Count<br>\u3000\u2018Me.ListBox1.s = i \u2013 1<br>\u3000textfile.WriteLine(Me.ListBox1.Items(i \u2013 1))<br>Next<\/p>\n\n\n\n<p>textfile.Close()<\/p>\n\n\n\n<p>End If<\/p>\n\n\n\n<p>End Sub<\/p>\n\n\n\n<p>End Class<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Read\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u3093\u3067ListBox\u306b\u8868\u793a\u3057\u307e\u3059\u3002\u307e\u305f\u3001\u30d4\u30af\u30c1\u30e3\u30dc\u30c3\u30af\u30b9\u306b\u3082\u8868\u793a\u3057\u307e\u3059\u3002Write\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001ListBox\u306e\u5185\u5bb9\u3092\u3001\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3078\u51fa\u529b\u3057\u307e\u3059\u3002 \u30d5\u30a9\u30fc\u30e0\uff11 Public &hellip; <a href=\"https:\/\/ekbt.info\/?p=2735\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u66f8\u304d&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"sfsi_plus_gutenberg_text_before_share":"","sfsi_plus_gutenberg_show_text_before_share":"","sfsi_plus_gutenberg_icon_type":"","sfsi_plus_gutenberg_icon_alignemt":"","sfsi_plus_gutenburg_max_per_row":"","footnotes":""},"categories":[138,10],"tags":[2093,2094],"class_list":["post-2735","post","type-post","status-publish","format-standard","hentry","category-visualstudio","category-win-pc-web","tag-2093","tag-2094"],"_links":{"self":[{"href":"https:\/\/ekbt.info\/index.php?rest_route=\/wp\/v2\/posts\/2735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ekbt.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ekbt.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ekbt.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ekbt.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2735"}],"version-history":[{"count":1,"href":"https:\/\/ekbt.info\/index.php?rest_route=\/wp\/v2\/posts\/2735\/revisions"}],"predecessor-version":[{"id":19338,"href":"https:\/\/ekbt.info\/index.php?rest_route=\/wp\/v2\/posts\/2735\/revisions\/19338"}],"wp:attachment":[{"href":"https:\/\/ekbt.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ekbt.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ekbt.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}