FileSystem.Input 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從開啟的序列檔案讀取資料,並將資料指派給變數。
多載
| 名稱 | Description |
|---|---|
| Input(Int32, Object) |
從開啟的序列檔案讀取資料,並將資料指派給變數。 |
| Input(Int32, Int64) |
從開啟的序列檔案讀取資料,並將資料指派給變數。 |
| Input(Int32, Int32) |
從開啟的序列檔案讀取資料,並將資料指派給變數。 |
| Input(Int32, Int16) |
從開啟的序列檔案讀取資料,並將資料指派給變數。 |
| Input(Int32, Double) |
從開啟的序列檔案讀取資料,並將資料指派給變數。 |
| Input(Int32, Boolean) |
從開啟的序列檔案讀取資料,並將資料指派給變數。 |
| Input(Int32, DateTime) |
從開啟的序列檔案讀取資料,並將資料指派給變數。 |
| Input(Int32, Char) |
從開啟的序列檔案讀取資料,並將資料指派給變數。 |
| Input(Int32, Byte) |
從開啟的序列檔案讀取資料,並將資料指派給變數。 |
| Input(Int32, Single) |
從開啟的序列檔案讀取資料,並將資料指派給變數。 |
| Input(Int32, Decimal) |
從開啟的序列檔案讀取資料,並將資料指派給變數。 |
| Input(Int32, String) |
從開啟的序列檔案讀取資料,並將資料指派給變數。 |
Input(Int32, Object)
從開啟的序列檔案讀取資料,並將資料指派給變數。
public:
static void Input(int FileNumber, System::Object ^ % Value);
public static void Input(int FileNumber, ref object Value);
static member Input : int * obj -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Object)
參數
- FileNumber
- Int32
必須的。 任何有效的檔案號碼。
- Value
- Object
必須的。 從檔案讀取值的變數——不能是陣列或物件變數。
例外狀況
檔案模式無效。
範例
此範例使用 Input 函式將資料從檔案讀取成兩個變數。 此範例假設 是一個 TestFile 檔案,包含多行資料,使用 Write 函式寫入,每行包含引號字串及逗號分隔的數字,例如:「Hello」,234頁。
FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)
備註
此功能 Input 是為了向下相容而設計,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 欲了解更多資訊,請參閱檔案存取Visual Basic。
讀取資料 Input 通常會透過 寫 Write入檔案。 此功能僅在檔案開啟於 Input 或 Binary 模式時使用。
Important
從檔案讀取時,不要根據副檔名來決定檔案內容。 例如,名為 Form1.vb 的檔案可能不是 2005 Visual Basic 原始碼檔案。
讀取時,標準字串或數值資料會被分配給變數,且不加修改。 下表說明其他輸入資料的處理方式。
| 數據 | 賦值給變數 |
|---|---|
| 逗號或空白線的分隔 | 空 |
| #NULL# | DBNull |
| #TRUE# 或 #FALSE# |
True 或 False |
#yyyy-mm-dd hh:mm:ss# |
該式所代表的日期和/或時間 |
#ERROR errornumber# |
errornumber (變數是標記為錯誤的物件) |
如果你在輸入資料項目時讀到檔案末尾,輸入會被停止並產生錯誤。
備註
這個 Input 函數並非局部化的。 例如,在德文版中,輸入 3,14159,只會回傳 3,因為逗號被視為變數分隔符,而非小數點。
Important
使用 Input 函式從檔案讀取需要 Read 從枚舉中 FileIOPermissionAccess 取得存取。 如需詳細資訊,請參閱FileIOPermissionAccess。
另請參閱
- InputString(Int32, Int32)
- FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)
- Print(Int32, Object[])
- PrintLine(Int32, Object[])
- Write(Int32, Object[])
- WriteLine(Int32, Object[])
如何:在 Visual Basic - 使用 Visual Basic 進行檔案存取
如何:使用 Streamwriter (Visual Basic)
適用於
Input(Int32, Int64)
從開啟的序列檔案讀取資料,並將資料指派給變數。
public:
static void Input(int FileNumber, long % Value);
public static void Input(int FileNumber, ref long Value);
static member Input : int * int64 -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Long)
參數
- FileNumber
- Int32
必須的。 任何有效的檔案號碼。
- Value
- Int64
必須的。 從檔案讀取值的變數——不能是陣列或物件變數。
例外狀況
檔案模式無效。
範例
此範例使用 Input 函式將資料從檔案讀取成兩個變數。 此範例假設 是一個 TestFile 檔案,包含多行資料,使用 Write 函式寫入,每行包含引號字串及逗號分隔的數字,例如:「Hello」,234頁。
FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)
備註
此功能 Input 是為了向下相容而設計,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 欲了解更多資訊,請參閱檔案存取Visual Basic。
讀取資料 Input 通常會透過 寫 Write入檔案。 此功能僅在檔案開啟於 Input 或 Binary 模式時使用。
Important
從檔案讀取時,不要根據副檔名來決定檔案內容。 例如,名為 Form1.vb 的檔案可能不是 2005 Visual Basic 原始碼檔案。
讀取時,標準字串或數值資料會被分配給變數,且不加修改。 下表說明其他輸入資料的處理方式。
| 數據 | 賦值給變數 |
|---|---|
| 逗號或空白線的分隔 | 空 |
| #NULL# | DBNull |
| #TRUE# 或 #FALSE# |
True 或 False |
#yyyy-mm-dd hh:mm:ss# |
該式所代表的日期和/或時間 |
#ERROR errornumber# |
errornumber (變數是標記為錯誤的物件) |
如果你在輸入資料項目時讀到檔案末尾,輸入會被停止並產生錯誤。
備註
這個 Input 函數並非局部化的。 例如,在德文版中,輸入 3,14159,只會回傳 3,因為逗號被視為變數分隔符,而非小數點。
Important
使用 Input 函式從檔案讀取需要 Read 從枚舉中 FileIOPermissionAccess 取得存取。 如需詳細資訊,請參閱FileIOPermissionAccess。
另請參閱
- InputString(Int32, Int32)
- FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)
- Print(Int32, Object[])
- PrintLine(Int32, Object[])
- Write(Int32, Object[])
- WriteLine(Int32, Object[])
如何:在 Visual Basic - 使用 Visual Basic 進行檔案存取
如何:使用 Streamwriter (Visual Basic)
適用於
Input(Int32, Int32)
從開啟的序列檔案讀取資料,並將資料指派給變數。
public:
static void Input(int FileNumber, int % Value);
public static void Input(int FileNumber, ref int Value);
static member Input : int * int -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Integer)
參數
- FileNumber
- Int32
必須的。 任何有效的檔案號碼。
- Value
- Int32
必須的。 從檔案讀取值的變數——不能是陣列或物件變數。
例外狀況
檔案模式無效。
範例
此範例使用 Input 函式將資料從檔案讀取成兩個變數。 此範例假設 是一個 TestFile 檔案,包含多行資料,使用 Write 函式寫入,每行包含引號字串及逗號分隔的數字,例如:「Hello」,234頁。
FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)
備註
此功能 Input 是為了向下相容而設計,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 欲了解更多資訊,請參閱檔案存取Visual Basic。
讀取資料 Input 通常會透過 寫 Write入檔案。 此功能僅在檔案開啟於 Input 或 Binary 模式時使用。
Important
從檔案讀取時,不要根據副檔名來決定檔案內容。 例如,名為 Form1.vb 的檔案可能不是 2005 Visual Basic 原始碼檔案。
讀取時,標準字串或數值資料會被分配給變數,且不加修改。 下表說明其他輸入資料的處理方式。
| 數據 | 賦值給變數 |
|---|---|
| 逗號或空白線的分隔 | 空 |
| #NULL# | DBNull |
| #TRUE# 或 #FALSE# |
True 或 False |
#yyyy-mm-dd hh:mm:ss# |
該式所代表的日期和/或時間 |
#ERROR errornumber# |
errornumber (變數是標記為錯誤的物件) |
如果你在輸入資料項目時讀到檔案末尾,輸入會被停止並產生錯誤。
備註
這個 Input 函數並非局部化的。 例如,在德文版本中,輸入 3,14159,僅回傳 3,因為逗號被視為變數分隔符而非小數點。
Important
使用 Input 函式從檔案讀取需要 Read 從枚舉中 FileIOPermissionAccess 取得存取。 如需詳細資訊,請參閱FileIOPermissionAccess。
另請參閱
- InputString(Int32, Int32)
- FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)
- Print(Int32, Object[])
- PrintLine(Int32, Object[])
- Write(Int32, Object[])
- WriteLine(Int32, Object[])
如何:在 Visual Basic - 使用 Visual Basic 進行檔案存取
如何:使用 Streamwriter (Visual Basic)
適用於
Input(Int32, Int16)
從開啟的序列檔案讀取資料,並將資料指派給變數。
public:
static void Input(int FileNumber, short % Value);
public static void Input(int FileNumber, ref short Value);
static member Input : int * int16 -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Short)
參數
- FileNumber
- Int32
必須的。 任何有效的檔案號碼。
- Value
- Int16
必須的。 從檔案讀取值的變數——不能是陣列或物件變數。
例外狀況
檔案模式無效。
範例
此範例使用 Input 函式將資料從檔案讀取成兩個變數。 此範例假設 是一個 TestFile 檔案,包含多行資料,使用 Write 函式寫入,每行包含引號字串及逗號分隔的數字,例如:「Hello」,234頁。
FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)
備註
此功能 Input 是為了向下相容而設計,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 欲了解更多資訊,請參閱檔案存取Visual Basic。
讀取資料 Input 通常會透過 寫 Write入檔案。 此功能僅在檔案開啟於 Input 或 Binary 模式時使用。
Important
從檔案讀取時,不要根據副檔名來決定檔案內容。 例如,名為 Form1.vb 的檔案可能不是 2005 Visual Basic 原始碼檔案。
讀取時,標準字串或數值資料會被分配給變數,且不加修改。 下表說明其他輸入資料的處理方式。
| 數據 | 賦值給變數 |
|---|---|
| 逗號或空白線的分隔 | 空 |
| #NULL# | DBNull |
| #TRUE# 或 #FALSE# |
True 或 False |
#yyyy-mm-dd hh:mm:ss# |
該式所代表的日期和/或時間 |
#ERROR errornumber# |
errornumber (變數是標記為錯誤的物件) |
如果你在輸入資料項目時讀到檔案末尾,輸入會被停止並產生錯誤。
備註
這個 Input 函數並非局部化的。 例如,在德文版中,輸入 3,14159,只會回傳 3,因為逗號被視為變數分隔符,而非小數點。
Important
使用 Input 函式從檔案讀取需要 Read 從枚舉中 FileIOPermissionAccess 取得存取。 如需詳細資訊,請參閱FileIOPermissionAccess。
另請參閱
- InputString(Int32, Int32)
- FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)
- Print(Int32, Object[])
- PrintLine(Int32, Object[])
- Write(Int32, Object[])
- WriteLine(Int32, Object[])
如何:在 Visual Basic - 使用 Visual Basic 進行檔案存取
如何:使用 Streamwriter (Visual Basic)
適用於
Input(Int32, Double)
從開啟的序列檔案讀取資料,並將資料指派給變數。
public:
static void Input(int FileNumber, double % Value);
public static void Input(int FileNumber, ref double Value);
static member Input : int * double -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Double)
參數
- FileNumber
- Int32
必須的。 任何有效的檔案號碼。
- Value
- Double
必須的。 從檔案讀取值的變數——不能是陣列或物件變數。
例外狀況
檔案模式無效。
範例
此範例使用 Input 函式將資料從檔案讀取成兩個變數。 此範例假設 是一個 TestFile 檔案,包含多行資料,使用 Write 函式寫入,每行包含引號字串及逗號分隔的數字,例如:「Hello」,234頁。
FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)
備註
此功能 Input 是為了向下相容而設計,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 欲了解更多資訊,請參閱檔案存取Visual Basic。
讀取資料 Input 通常會透過 寫 Write入檔案。 此功能僅在檔案開啟於 Input 或 Binary 模式時使用。
Important
從檔案讀取時,不要根據副檔名來決定檔案內容。 例如,名為 Form1.vb 的檔案可能不是 2005 Visual Basic 原始碼檔案。
讀取時,標準字串或數值資料會被分配給變數,且不加修改。 下表說明其他輸入資料的處理方式。
| 數據 | 賦值給變數 |
|---|---|
| 逗號或空白線的分隔 | 空 |
| #NULL# | DBNull |
| #TRUE# 或 #FALSE# |
True 或 False |
#yyyy-mm-dd hh:mm:ss# |
該式所代表的日期和/或時間 |
#ERROR errornumber# |
errornumber (變數是標記為錯誤的物件) |
如果你在輸入資料項目時讀到檔案末尾,輸入會被停止並產生錯誤。
備註
這個 Input 函數並非局部化的。 例如,在德文版中,輸入 3,14159,只會回傳 3,因為逗號被視為變數分隔符,而非小數點。
Important
使用 Input 函式從檔案讀取需要 Read 從枚舉中 FileIOPermissionAccess 取得存取。 如需詳細資訊,請參閱FileIOPermissionAccess。
另請參閱
- InputString(Int32, Int32)
- FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)
- Print(Int32, Object[])
- PrintLine(Int32, Object[])
- Write(Int32, Object[])
- WriteLine(Int32, Object[])
如何:在 Visual Basic - 使用 Visual Basic 進行檔案存取
如何:使用 Streamwriter (Visual Basic)
適用於
Input(Int32, Boolean)
從開啟的序列檔案讀取資料,並將資料指派給變數。
public:
static void Input(int FileNumber, bool % Value);
public static void Input(int FileNumber, ref bool Value);
static member Input : int * bool -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Boolean)
參數
- FileNumber
- Int32
必須的。 任何有效的檔案號碼。
- Value
- Boolean
必須的。 從檔案讀取值的變數——不能是陣列或物件變數。
例外狀況
檔案模式無效。
範例
此範例使用 Input 函式將資料從檔案讀取成兩個變數。 此範例假設 是一個 TestFile 檔案,裡面有幾行資料是用函 Write 式寫入,每行包含一個引號字串和一個逗號分隔的數字,例如:「Hello」,234頁。
FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)
備註
此功能 Input 是為了向下相容而設計,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 欲了解更多資訊,請參閱檔案存取Visual Basic。
讀取資料 Input 通常會透過 寫 Write入檔案。 此功能僅在檔案開啟於 Input 或 Binary 模式時使用。
Important
從檔案讀取時,不要根據副檔名來決定檔案內容。 例如,名為 Form1.vb 的檔案可能不是 2005 Visual Basic 原始碼檔案。
讀取時,標準字串或數值資料會被分配給變數,且不加修改。 下表說明其他輸入資料的處理方式。
| 數據 | 賦值給變數 |
|---|---|
| 逗號或空白線的分隔 | 空 |
| #NULL# | DBNull |
| #TRUE# 或 #FALSE# |
True 或 False |
#yyyy-mm-dd hh:mm:ss# |
該式所代表的日期和/或時間 |
#ERROR errornumber# |
errornumber (變數是標記為錯誤的物件) |
如果你在輸入資料項目時讀到檔案末尾,輸入會被停止並產生錯誤。
備註
這個 Input 函數並非局部化的。 例如,在德文版中,輸入 3,14159,只會回傳 3,因為逗號被視為變數分隔符,而非小數點。
Important
使用 Input 函式從檔案讀取需要 Read 從枚舉中 FileIOPermissionAccess 取得存取。 如需詳細資訊,請參閱FileIOPermissionAccess。
另請參閱
- InputString(Int32, Int32)
- FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)
- Print(Int32, Object[])
- PrintLine(Int32, Object[])
- Write(Int32, Object[])
- WriteLine(Int32, Object[])
如何:在 Visual Basic - 使用 Visual Basic 進行檔案存取
如何:使用 Streamwriter (Visual Basic)
適用於
Input(Int32, DateTime)
從開啟的序列檔案讀取資料,並將資料指派給變數。
public:
static void Input(int FileNumber, DateTime % Value);
public static void Input(int FileNumber, ref DateTime Value);
static member Input : int * DateTime -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As DateTime)
參數
- FileNumber
- Int32
必須的。 任何有效的檔案號碼。
- Value
- DateTime
必須的。 從檔案讀取值的變數——不能是陣列或物件變數。
例外狀況
檔案模式無效。
範例
此範例使用 Input 函式將資料從檔案讀取成兩個變數。 此範例假設 是一個 TestFile 檔案,包含多行資料,使用 Write 函式寫入,每行包含引號字串及逗號分隔的數字,例如:「Hello」,234頁。
FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)
備註
此功能 Input 是為了向下相容而設計,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 欲了解更多資訊,請參閱檔案存取Visual Basic。
讀取資料 Input 通常會透過 寫 Write入檔案。 此功能僅在檔案開啟於 Input 或 Binary 模式時使用。
Important
從檔案讀取時,不要根據副檔名來決定檔案內容。 例如,名為 Form1.vb 的檔案可能不是 2005 Visual Basic 原始碼檔案。
讀取時,標準字串或數值資料會被分配給變數,且不加修改。 下表說明其他輸入資料的處理方式。
| 數據 | 賦值給變數 |
|---|---|
| 逗號或空白線的分隔 | 空 |
| #NULL# | DBNull |
| #TRUE# 或 #FALSE# |
True 或 False |
#yyyy-mm-dd hh:mm:ss# |
該式所代表的日期和/或時間 |
#ERROR errornumber# |
errornumber (變數是標記為錯誤的物件) |
如果你在輸入資料項目時讀到檔案末尾,輸入會被停止並產生錯誤。
備註
這個 Input 函數並非局部化的。 例如,在德文版中,輸入 3,14159,只會回傳 3,因為逗號被視為變數分隔符,而非小數點。
Important
使用 Input 函式從檔案讀取需要 Read 從枚舉中 FileIOPermissionAccess 取得存取。 如需詳細資訊,請參閱FileIOPermissionAccess。
另請參閱
- InputString(Int32, Int32)
- FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)
- Print(Int32, Object[])
- PrintLine(Int32, Object[])
- Write(Int32, Object[])
- WriteLine(Int32, Object[])
如何:在 Visual Basic - 使用 Visual Basic 進行檔案存取
如何:使用 Streamwriter (Visual Basic)
適用於
Input(Int32, Char)
從開啟的序列檔案讀取資料,並將資料指派給變數。
public:
static void Input(int FileNumber, char % Value);
public static void Input(int FileNumber, ref char Value);
static member Input : int * char -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Char)
參數
- FileNumber
- Int32
必須的。 任何有效的檔案號碼。
- Value
- Char
必須的。 從檔案讀取值的變數——不能是陣列或物件變數。
例外狀況
檔案模式無效。
範例
此範例使用 Input 函式將資料從檔案讀取成兩個變數。 此範例假設 是一個 TestFile 檔案,包含多行資料,使用 Write 函式寫入,每行包含引號字串及逗號分隔的數字,例如:「Hello」,234頁。
FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)
備註
此功能 Input 是為了向下相容而設計,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 欲了解更多資訊,請參閱檔案存取Visual Basic。
讀取資料 Input 通常會透過 寫 Write入檔案。 此功能僅在檔案開啟於 Input 或 Binary 模式時使用。
Important
從檔案讀取時,不要根據副檔名來決定檔案內容。 例如,名為 Form1.vb 的檔案可能不是 2005 Visual Basic 原始碼檔案。
讀取時,標準字串或數值資料會被分配給變數,且不加修改。 下表說明其他輸入資料的處理方式。
| 數據 | 賦值給變數 |
|---|---|
| 逗號或空白線的分隔 | 空 |
| #NULL# | DBNull |
| #TRUE# 或 #FALSE# |
True 或 False |
#yyyy-mm-dd hh:mm:ss# |
該式所代表的日期和/或時間 |
#ERROR errornumber# |
errornumber (變數是標記為錯誤的物件) |
如果你在輸入資料項目時讀到檔案末尾,輸入會被停止並產生錯誤。
備註
這個 Input 函數並非局部化的。 例如,在德文版中,輸入 3,14159,只會回傳 3,因為逗號被視為變數分隔符,而非小數點。
Important
使用 Input 函式從檔案讀取需要 Read 從枚舉中 FileIOPermissionAccess 取得存取。 如需詳細資訊,請參閱FileIOPermissionAccess。
另請參閱
- InputString(Int32, Int32)
- FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)
- Print(Int32, Object[])
- PrintLine(Int32, Object[])
- Write(Int32, Object[])
- WriteLine(Int32, Object[])
如何:在 Visual Basic - 使用 Visual Basic 進行檔案存取
如何:使用 Streamwriter (Visual Basic)
適用於
Input(Int32, Byte)
從開啟的序列檔案讀取資料,並將資料指派給變數。
public:
static void Input(int FileNumber, System::Byte % Value);
public static void Input(int FileNumber, ref byte Value);
static member Input : int * byte -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Byte)
參數
- FileNumber
- Int32
必須的。 任何有效的檔案號碼。
- Value
- Byte
必須的。 從檔案讀取值的變數——不能是陣列或物件變數。
例外狀況
檔案模式無效。
範例
此範例使用 Input 函式將資料從檔案讀取成兩個變數。 此範例假設 是一個 TestFile 檔案,裡面有幾行資料是用函 Write 式寫入,每行包含一個引號字串和一個逗號分隔的數字,例如:「Hello」,234頁。
FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)
備註
此功能 Input 是為了向下相容而設計,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 欲了解更多資訊,請參閱檔案存取Visual Basic。
讀取資料 Input 通常會透過 寫 Write入檔案。 此功能僅在檔案開啟於 Input 或 Binary 模式時使用。
Important
從檔案讀取時,不要根據副檔名來決定檔案內容。 例如,名為 Form1.vb 的檔案可能不是 2005 Visual Basic 原始碼檔案。
讀取時,標準字串或數值資料會被分配給變數,且不加修改。 下表說明其他輸入資料的處理方式。
| 數據 | 賦值給變數 |
|---|---|
| 逗號或空白線的分隔 | 空 |
| #NULL# | DBNull |
| #TRUE# 或 #FALSE# |
True 或 False |
#yyyy-mm-dd hh:mm:ss# |
該式所代表的日期和/或時間 |
#ERROR errornumber# |
errornumber (變數是標記為錯誤的物件) |
如果你在輸入資料項目時讀到檔案末尾,輸入會被停止並產生錯誤。
備註
這個 Input 函數並非局部化的。 例如,在德文版中,輸入 3,14159,只會回傳 3,因為逗號被視為變數分隔符,而非小數點。
Important
使用 Input 函式從檔案讀取需要 Read 從枚舉中 FileIOPermissionAccess 取得存取。 如需詳細資訊,請參閱FileIOPermissionAccess。
另請參閱
- InputString(Int32, Int32)
- FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)
- Print(Int32, Object[])
- PrintLine(Int32, Object[])
- Write(Int32, Object[])
- WriteLine(Int32, Object[])
如何:在 Visual Basic - 使用 Visual Basic 進行檔案存取
如何:使用 Streamwriter (Visual Basic)
適用於
Input(Int32, Single)
從開啟的序列檔案讀取資料,並將資料指派給變數。
public:
static void Input(int FileNumber, float % Value);
public static void Input(int FileNumber, ref float Value);
static member Input : int * single -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Single)
參數
- FileNumber
- Int32
必須的。 任何有效的檔案號碼。
- Value
- Single
必須的。 從檔案讀取值的變數——不能是陣列或物件變數。
例外狀況
檔案模式無效。
範例
此範例使用 Input 函式將資料從檔案讀取成兩個變數。 此範例假設 是一個 TestFile 檔案,包含多行資料,使用 Write 函式寫入,每行包含引號字串及逗號分隔的數字,例如:「Hello」,234頁。
FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)
備註
此功能 Input 是為了向下相容而設計,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 欲了解更多資訊,請參閱檔案存取Visual Basic。
讀取資料 Input 通常會透過 寫 Write入檔案。 此功能僅在檔案開啟於 Input 或 Binary 模式時使用。
Important
從檔案讀取時,不要根據副檔名來決定檔案內容。 例如,名為 Form1.vb 的檔案可能不是 2005 Visual Basic 原始碼檔案。
讀取時,標準字串或數值資料會被分配給變數,且不加修改。 下表說明其他輸入資料的處理方式。
| 數據 | 賦值給變數 |
|---|---|
| 逗號或空白線的分隔 | 空 |
| #NULL# | DBNull |
| #TRUE# 或 #FALSE# |
True 或 False |
#yyyy-mm-dd hh:mm:ss# |
該式所代表的日期和/或時間 |
#ERROR errornumber# |
errornumber (變數是標記為錯誤的物件) |
如果你在輸入資料項目時讀到檔案末尾,輸入會被停止並產生錯誤。
備註
這個 Input 函數並非局部化的。 例如,在德文版中,輸入 3,14159,只會回傳 3,因為逗號被視為變數分隔符,而非小數點。
Important
使用 Input 函式從檔案讀取需要 Read 從枚舉中 FileIOPermissionAccess 取得存取。 如需詳細資訊,請參閱FileIOPermissionAccess。
另請參閱
- InputString(Int32, Int32)
- FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)
- Print(Int32, Object[])
- PrintLine(Int32, Object[])
- Write(Int32, Object[])
- WriteLine(Int32, Object[])
如何:在 Visual Basic - 使用 Visual Basic 進行檔案存取
如何:使用 Streamwriter (Visual Basic)
適用於
Input(Int32, Decimal)
從開啟的序列檔案讀取資料,並將資料指派給變數。
public:
static void Input(int FileNumber, System::Decimal % Value);
public static void Input(int FileNumber, ref decimal Value);
static member Input : int * decimal -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Decimal)
參數
- FileNumber
- Int32
必須的。 任何有效的檔案號碼。
- Value
- Decimal
必須的。 從檔案讀取值的變數——不能是陣列或物件變數。
例外狀況
檔案模式無效。
範例
此範例使用 Input 函式將資料從檔案讀取成兩個變數。 此範例假設 是一個 TestFile 檔案,包含多行資料,使用 Write 函式寫入,每行包含引號字串及逗號分隔的數字,例如:「Hello」,234頁。
FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)
備註
此功能 Input 是為了向下相容而設計,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 欲了解更多資訊,請參閱檔案存取Visual Basic。
讀取資料 Input 通常會透過 寫 Write入檔案。 此功能僅在檔案開啟於 Input 或 Binary 模式時使用。
Important
從檔案讀取時,不要根據副檔名來決定檔案內容。 例如,名為 Form1.vb 的檔案可能不是 2005 Visual Basic 原始碼檔案。
讀取時,標準字串或數值資料會被分配給變數,且不加修改。 下表說明其他輸入資料的處理方式。
| 數據 | 賦值給變數 |
|---|---|
| 逗號或空白線的分隔 | 空 |
| #NULL# | DBNull |
| #TRUE# 或 #FALSE# |
True 或 False |
#yyyy-mm-dd hh:mm:ss# |
該式所代表的日期和/或時間 |
#ERROR errornumber# |
errornumber (變數是標記為錯誤的物件) |
如果你在輸入資料項目時讀到檔案末尾,輸入會被停止並產生錯誤。
備註
這個 Input 函數並非局部化的。 例如,在德文版中,輸入 3,14159,只會回傳 3,因為逗號被視為變數分隔符,而非小數點。
Important
使用 Input 函式從檔案讀取需要 Read 從枚舉中 FileIOPermissionAccess 取得存取。 如需詳細資訊,請參閱FileIOPermissionAccess。
另請參閱
- InputString(Int32, Int32)
- FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)
- Print(Int32, Object[])
- PrintLine(Int32, Object[])
- Write(Int32, Object[])
- WriteLine(Int32, Object[])
如何:在 Visual Basic - 使用 Visual Basic 進行檔案存取
如何:使用 Streamwriter (Visual Basic)
適用於
Input(Int32, String)
從開啟的序列檔案讀取資料,並將資料指派給變數。
public:
static void Input(int FileNumber, System::String ^ % Value);
public static void Input(int FileNumber, ref string Value);
static member Input : int * string -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As String)
參數
- FileNumber
- Int32
必須的。 任何有效的檔案號碼。
- Value
- String
必須的。 從檔案讀取值的變數——不能是陣列或物件變數。
例外狀況
檔案模式無效。
範例
此範例使用 Input 函式將資料從檔案讀取成兩個變數。 此範例假設 是一個 TestFile 檔案,包含多行資料,使用 Write 函式寫入,每行包含引號字串及逗號分隔的數字,例如:「Hello」,234頁。
FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)
備註
此功能 Input 是為了向下相容而設計,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 欲了解更多資訊,請參閱檔案存取Visual Basic。
讀取資料 Input 通常會透過 寫 Write入檔案。 此功能僅在檔案開啟於 Input 或 Binary 模式時使用。
Important
從檔案讀取時,不要根據副檔名來決定檔案內容。 例如,名為 Form1.vb 的檔案可能不是 2005 Visual Basic 原始碼檔案。
讀取時,標準字串或數值資料會被分配給變數,且不加修改。 下表說明其他輸入資料的處理方式。
| 數據 | 賦值給變數 |
|---|---|
| 逗號或空白線的分隔 | 空 |
| #NULL# | DBNull |
| #TRUE# 或 #FALSE# |
True 或 False |
#yyyy-mm-dd hh:mm:ss# |
該式所代表的日期和/或時間 |
#ERROR errornumber# |
errornumber (變數是標記為錯誤的物件) |
如果你在輸入資料項目時讀到檔案末尾,輸入會被停止並產生錯誤。
備註
這個 Input 函數並非局部化的。 例如,在德文版中,輸入 3,14159,只會回傳 3,因為逗號被視為變數分隔符,而非小數點。
Important
使用 Input 函式從檔案讀取需要 Read 從枚舉中 FileIOPermissionAccess 取得存取。 如需詳細資訊,請參閱FileIOPermissionAccess。
另請參閱
- InputString(Int32, Int32)
- FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)
- Print(Int32, Object[])
- PrintLine(Int32, Object[])
- Write(Int32, Object[])
- WriteLine(Int32, Object[])
如何:在 Visual Basic - 使用 Visual Basic 進行檔案存取
如何:使用 Streamwriter (Visual Basic)