level 12
分割成数组,然后判断第一个字符是不是数字进行分类放进list
2018年02月08日 00点02分
2
level 13
Public Class frmRental
'Class Level Private variables
Private _intCities As Integer = 10
Public Shared _intSizeofArray As Integer = 9
Public Shared _strCities(_intSizeofArray) As String
Private _strCityName(_intSizeofArray) As String
Private _decRentalCost(_intSizeofArray) As Decimal
Private _decAverageCost(_intSizeofArray) As Decimal
Private Sub frmRental_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'The frmRental load event reads the rentals.txt files and fills the Listbox object with the city names
'Initialize an instance of streameReader object and declare varibles
Dim objReader As IO.StreamReader
Dim strLocationAndNameofFile As String = "G:\google download\RJCCIT-218Spring\RJCCIT-218Spring\vb2017\Student data files\Chapter 8\rentals.txt"
Dim intCount As Integer = 0
Dim intFill As Integer
Dim strFileError As String = "The file is not available. Restart when the file is available."
'Verift the file exists
If IO.File.Exists(strLocationAndNameofFile) Then
objReader = IO.File.OpenText(strLocationAndNameofFile)
'Read the file line by line until the file is completed
Do While objReader.Peek <> 1
_strCities(intCount) = objReader.ReadLine()
intCount += 1
Loop
'The Listbox object is filled with the city names
For intFill = 0 To (_strCities.Length - 1)
lstCities.Items.Add(_strCities(intFill))
Next
Else
MsgBox(strFileError, , "Error")
Close()
End If
End Sub
End Class
2018年02月08日 01点02分
3
level 7
Open "C:\123.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, a
If IsNumeric(a) = True Then
List2.AddItem a
Else
List1.AddItem a
End If
Loop
Close #1
2018年02月08日 01点02分
4
level 11
这么规整的txt文件,还用那么复杂吗?
Open "C:\123.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, a
List1.AddItem a
Line Input #1, a
List2.AddItem
Loop
Close #1
应该就可以了
2018年02月09日 01点02分
6