"Keith (Southend)G" <
[email protected]> wrote in message
Hi Jack,
A lot of errors here, looks like I need to be declaring a few things
or something to do with Local / Private. Sorry to have to post the
whole code, but you may see where it's going wrong. I tried a few
things, like removing the 'Private', which cut down the errors, but
I'm sure this does something that's required.
Error 1 to 4 'Private' is not valid on a local constant declaration. C:
\Documents and Settings\Keith\My Documents\Visual Studio 2008\Projects
\Open Text\Open Text\Form1.vb 31 9 Open Text
Error 5 Statement cannot appear within a method body. End of method
assumed. C:\Documents and Settings\Keith\My Documents\Visual Studio
2008\Projects\Open Text\Open Text\Form1.vb 36 5 Open Text
Error 6 Name 'InputFile' is not declared. C:\Documents and Settings
\Keith\My Documents\Visual Studio 2008\Projects\Open Text\Open Text
\Form1.vb 37 50 Open Text
Error 7 Expression expected. C:\Documents and Settings\Keith\My
Documents\Visual Studio 2008\Projects\Open Text\Open Text\Form1.vb 40
51 Open Text
Error 8 Property access must assign to the property or use its value.
C:\Documents and Settings\Keith\My Documents\Visual Studio
2008\Projects\Open Text\Open Text\Form1.vb 41 1 Open Text
Error 9 End of statement expected. C:\Documents and Settings\Keith\My
Documents\Visual Studio 2008\Projects\Open Text\Open Text\Form1.vb 41
27 Open Text
Error 10 Method arguments must be enclosed in parentheses. C:
\Documents and Settings\Keith\My Documents\Visual Studio 2008\Projects
\Open Text\Open Text\Form1.vb 41 27 Open Text
Error 11 & 12 Name 'Writer' is not declared. C:\Documents and Settings
\Keith\My Documents\Visual Studio 2008\Projects\Open Text\Open Text
\Form1.vb 48 21 Open Text
Error 13 Declaration expected. C:\Documents and Settings\Keith\My
Documents\Visual Studio 2008\Projects\Open Text\Open Text\Form1.vb 102
21 Open Text
Error 14 & 15 'End While' must be preceded by a matching 'While'. C:
\Documents and Settings\Keith\My Documents\Visual Studio 2008\Projects
\Open Text\Open Text\Form1.vb 103 17 Open Text
Error 16,17,19 Declaration expected. C:\Documents and Settings\Keith
\My Documents\Visual Studio 2008\Projects\Open Text\Open Text\Form1.vb
105 13 Open Text
Error 18 Statement cannot appear outside of a method body. C:
\Documents and Settings\Keith\My Documents\Visual Studio 2008\Projects
\Open Text\Open Text\Form1.vb 107 9 Open Text
Error 20 'End If' must be preceded by a matching 'If'. C:\Documents
and Settings\Keith\My Documents\Visual Studio 2008\Projects\Open Text
\Open Text\Form1.vb 109 9 Open Text
Error 21 'End Sub' must be preceded by a matching 'Sub'. C:\Documents
and Settings\Keith\My Documents\Visual Studio 2008\Projects\Open Text
\Open Text\Form1.vb 110 5 Open Text
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim FILE_NAME As String = "C:\ogimet.txt"
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
RichTextBox1.Text = objReader.ReadToEnd
objReader.Close()
Else
MsgBox("File Does Not Exist")
End If
End Sub
Private Sub TabPage1_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
End Sub
Private Sub RichTextBox1_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RichTextBox1.TextChanged
End Sub
Private Sub RichTextBox2_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RichTextBox2.TextChanged
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
Private Const InputFolder As String = "C:\"
Private Const InputFile As String = InputFolder & "ogimet.txt"
Private Const OutputFolder As String = "C:\"
Private Const OutputFile As String = OutputFolder &
"sorted.txt"
Private Sub ProcessInput()
Dim Reader As New System.IO.StreamReader(InputFile, _
System.Text.Encoding.ASCII)
Dim Writer As New System.IO.StreamWriter(OutputFile, _
False,
System.Text.Encoding.ASCII)
Dim InputLine As String = ""
Do
InputLine = GetNextLine(Reader)
If InputLine > "" Then
Dim OutputLine As String = ParseInput(InputLine)
If OutputLine > "" Then
Writer.WriteLine(OutputLine)
End If
End If
Loop Until InputLine = ""
Writer.Close()
Reader.Close()
End Sub
Private Function GetNextLine(ByVal FromReader As
System.IO.StreamReader) _
As String
Dim Result As String = ""
Dim InsideDataLine As Boolean = False
Dim Buffer As String = ""
Do
Buffer = FromReader.ReadLine
If Buffer IsNot Nothing Then
If Not InsideDataLine Then
If Buffer.Length >= 4 AndAlso _
Buffer.Substring(0, 4) Like "2[0-9][0-9][0-9]"
Then
Result = Buffer.Trim
If Result.EndsWith("=") Then
Exit Do
End If
InsideDataLine = True
End If
Else
Result &= " " & Buffer.Trim
If Buffer.EndsWith("=") Then
Exit Do
End If
End If
End If
Loop Until Buffer Is Nothing
Return Result
End Function
Private Function ParseInput(ByVal InputString As String) As String
Dim ItemList() As String = Split(InputString, " ")
Dim NewLine As String = ""
If ItemList.Length > 2 AndAlso ItemList(1) = "AAXX" Then
Dim Year As Integer = CInt(ItemList(0).Substring(0, 4))
Dim Month As Integer = CInt(ItemList(0).Substring(4, 2))
Dim Day As Integer = CInt(ItemList(2).Substring(0, 2))
Dim Hours As Integer = CInt(ItemList(2).Substring(2, 2))
Dim LineDate As Date = DateSerial(Year, Month,
Day).AddHours(Hours)
NewLine = ItemList(2)
For Counter As Integer = 3 To ItemList.Length - 1
NewLine &= " " & ItemList(Counter)
Next
End If
Return NewLine
End Function
input = sr.ReadLine()
End While
End Using
objWriter.Close()
MsgBox("Text written to file")
Else
MsgBox("File Does Not Exist")
End If
End Sub
End Class
This has been very useful as it has made me realize how much there is
to this and that I need to understand precisely what each line is
doing, which you explained well in your previous post. It's a shame I
couldn't unroll on a class locally, but you only get very basic
computer courses, not programming and the like. It's frustrating as I
could save myself so much time and anguish, the trouble is the weather
data never stops, so I'm chasing rainbows, which uses the time I need
to learn this. However, I'm not giving up yet ;-)
Many thanks
Keith (Southend)