| | |
Reading unicode text from a sequential file
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2008
Posts: 2
Reputation:
Solved Threads: 0
I am using visual basic 2005 in visual studio 2005. When I try to input unicode data from a sequential txt file using (LineInput(#)) I get question marks eg. (?????? ?????) for all the unicode characters (in this case TNR Greek) in the line, or the command, LineInput(#) doesn't work at all. I am looking for code to allow me to read such line from a txt file. Depending on how I create the file the unicode characters will or will not properly display in MS Notepad. In either case the code I am trying to use does not work. Here is the code I am currently using:
Public Class ReadData
Private Sub GetVariable(ByVal Delimit As String, ByRef L As String, ByRef V As String)
Dim Ld As Integer
'Find Delimiter
Ld = InStr(L, Delimit) - 1
If Ld < 0 Then
Ld = Len(L)
End If
'Extract String Value
V = Mid(L, 1, Ld)
'Shorten Line
L = Trim(Mid(L, Ld + 1, Len(L) - Ld))
End Sub
Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRead.Click
Dim HymnIndex(100) As Integer, HymnName(100) As String, VolumeID(100) As Integer, PDFPageNo(100) As Integer
Dim Myline As String, VariableString As String
Dim I As Integer
'set starting value of I the array index)
I = 1
FileOpen(1, Application.StartupPath + "\VelonIndex.txt", OpenMode.Input)
'Read lines until EOF is reached
Do Until EOF(1)
Myline = LineInput(1)
MessageBox.Show(Myline, "Input Line")
'strip off the leading and trailing spaces
Trim(Myline)
'Find HymnIndex in each line as an Integer
Call GetVariable(" ", Myline, VariableString)
HymnIndex(I) = CInt(Val(VariableString))
lstData.Items.Add("Hymn Index = " + CStr(HymnIndex(I)))
'Find HymnName in each line - two spaces are the delimiter
Call GetVariable(" ", Myline, VariableString)
HymnName(I) = Trim(VariableString)
lstData.Items.Add("Hymn Name = " + HymnName(I))
Call GetVariable(" ", Myline, VariableString)
VolumeID(I) = CInt(Val(VariableString))
lstData.Items.Add("Volume ID = " + CStr(VolumeID(I)))
Call GetVariable(" ", Myline, VariableString)
PDFPageNo(I) = CInt(Val(VariableString))
lstData.Items.Add("PDF Page Number = " + CStr(PDFPageNo(I)))
I += 1
Loop
FileClose()
End Sub
End Class
Public Class ReadData
Private Sub GetVariable(ByVal Delimit As String, ByRef L As String, ByRef V As String)
Dim Ld As Integer
'Find Delimiter
Ld = InStr(L, Delimit) - 1
If Ld < 0 Then
Ld = Len(L)
End If
'Extract String Value
V = Mid(L, 1, Ld)
'Shorten Line
L = Trim(Mid(L, Ld + 1, Len(L) - Ld))
End Sub
Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRead.Click
Dim HymnIndex(100) As Integer, HymnName(100) As String, VolumeID(100) As Integer, PDFPageNo(100) As Integer
Dim Myline As String, VariableString As String
Dim I As Integer
'set starting value of I the array index)
I = 1
FileOpen(1, Application.StartupPath + "\VelonIndex.txt", OpenMode.Input)
'Read lines until EOF is reached
Do Until EOF(1)
Myline = LineInput(1)
MessageBox.Show(Myline, "Input Line")
'strip off the leading and trailing spaces
Trim(Myline)
'Find HymnIndex in each line as an Integer
Call GetVariable(" ", Myline, VariableString)
HymnIndex(I) = CInt(Val(VariableString))
lstData.Items.Add("Hymn Index = " + CStr(HymnIndex(I)))
'Find HymnName in each line - two spaces are the delimiter
Call GetVariable(" ", Myline, VariableString)
HymnName(I) = Trim(VariableString)
lstData.Items.Add("Hymn Name = " + HymnName(I))
Call GetVariable(" ", Myline, VariableString)
VolumeID(I) = CInt(Val(VariableString))
lstData.Items.Add("Volume ID = " + CStr(VolumeID(I)))
Call GetVariable(" ", Myline, VariableString)
PDFPageNo(I) = CInt(Val(VariableString))
lstData.Items.Add("PDF Page Number = " + CStr(PDFPageNo(I)))
I += 1
Loop
FileClose()
End Sub
End Class
Last edited by Georgestef; Jan 25th, 2008 at 1:53 pm.
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: Moving a captured bitmap picture across a LAN nework
- Next Thread: Changing Listbox item text
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2005 2008 access account application arithmetic array arrays basic bing button buttons c# center check checkbox code convert crystalreport data database datagrid datagridview date dissertation dissertations dropdownlist excel fade file-dialog filter ftp generatetags google gridview hardcopy images inline input insert intel internet listview mobile monitor ms net networking objects output panel passingparameters picturebox picturebox1 port position print printing problem project read remove save searchbox searchvb.net select serial server shutdown soap sorting survey table tcp temperature text textbox timer timespan toolbox trim update user validation vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet visual visualbasic visualbasic.net visualstudio2008 web webbrowser winforms wpf year





