Dim instance As StdFunc = New StdFunc() Dim filePathName As String 'ファイルのフルパス Dim returnValue As String() '成功:文字列配列 失敗:Nothing returnValue = instance.FileReadLines(filePathName) 'エンコード指定なしの場合はUTF-8として読込
Dim instance As StdFunc = New StdFunc() Dim filePathName As String 'ファイルのフルパス Dim encodeStr As String 'エンコードを表す文字列 "utf8" "shift_jis" "iso-2022-jp" "euc-jp" Dim returnValue As String() '成功:文字列配列 失敗:Nothing returnValue = instance.FileReadLines(filePathName, encodeStr)
Dim instance As StdFunc = New StdFunc() Dim filePathName As String 'ファイルのフルパス Dim encode As System.Text.Encoding 'エンコード Dim returnValue As String() '成功:文字列配列 失敗:Nothing returnValue = instance.FileReadLines(filePathName, encode)
'StdFuncクラス FileReadLinesメソッド Imports System Imports System.Windows.Forms Imports Microsoft.VisualBasic Public Class AddIn Private stdf As StdFunc Public Sub New() stdf = New StdFunc() End Sub Public Sub AddIn_Start() Dim fname As String = "D:\tmp\input.txt" Dim ary As String() = stdf.FileReadLines(fname) If ary Is Nothing Then MessageBox.Show("読み込みに失敗しました") Else Dim result As String = "" Dim num As Integer = 1 For Each s As String In ary result &= num.ToString & " : " & s & ControlChars.CrLf num += 1 Next MessageBox.Show(result) End If End Sub End Class
'StdFuncクラス FileReadLinesメソッド Imports System Imports System.Windows.Forms Imports Microsoft.VisualBasic Public Class AddIn Private stdf As StdFunc Public Sub New() stdf = New StdFunc() End Sub Public Sub AddIn_Start() Dim fname As String = "D:\tmp\input.txt" Dim ary As String() = stdf.FileReadLines(fname, "euc-jp") If ary Is Nothing Then MessageBox.Show("読み込みに失敗しました") Else Dim result As String = "" Dim num As Integer = 1 For Each s As String In ary result &= num.ToString & " : " & s & ControlChars.CrLf num += 1 Next MessageBox.Show(result) End If End Sub End Class
'StdFuncクラス FileReadLinesメソッド Imports System Imports System.Windows.Forms Imports Microsoft.VisualBasic Public Class AddIn Private stdf As StdFunc Public Sub New() stdf = New StdFunc() End Sub Public Sub AddIn_Start() Dim fname As String = "D:\tmp\input.txt" Dim ary As String() _ = stdf.FileReadLines(fname, System.Text.Encoding.GetEncoding(932)) If ary Is Nothing Then MessageBox.Show("読み込みに失敗しました") Else Dim result As String = "" Dim num As Integer = 1 For Each s As String In ary result &= num.ToString & " : " & s & ControlChars.CrLf num += 1 Next MessageBox.Show(result) End If End Sub End Class
このページのQRコード
便利ウェブサイト
便利 Android アプリ
便利 iOS(iPhone,iPad) アプリ