From: Keith (Southend)G on
On Jan 13, 9:51 pm, "Captain Jack" <CaptainJack1...(a)comcast.net>
wrote:
> "Keith (Southend)G" <keith_harr...(a)hotmail.com> wrote in message
>
> news:2d5e108a-193f-46e9-b0d5-d163f51ce54f(a)22g2000yqr.googlegroups.com...
>
>
>
> > 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)
>
> Sure thing. :-)
>
> Looks like it should be easy to fix. Everything that's inside the sub
> Button2_Click needs to go outside of it. Some of the declarations (like
> Private Const) can't be inside the sub definition, they have to be in the
> class definition. If you move all of that code out (say, put it after the
> End Sub) then Button2_Click just needs to look like this:
>
> Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button2.Click
>     ProcessInput()
> End Sub
>
> What will happen then is that, when Button2 is clicked, th ProcessInput sub
> will be run, which will in turn run the other subs. But all of the subs,
> functions, and variables declared with Private scope have to be outside of
> the sub; that way, VB knows where to find them. Right now, VB is seeing
> those things inside of the sub, and it just doesn't like them to be there..
>
> --
> Jack

Something needs to go between End Sub and Private Const?
Class definition? That's right at the top. Down to 15 errors now.

Keith (Southend)


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
ProcessInput()
End Sub

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()
From: Keith (Southend)G on
On Jan 13, 10:50 pm, "Keith (Southend)G" <keith_harr...(a)hotmail.com>
wrote:
> On Jan 13, 9:51 pm, "Captain Jack" <CaptainJack1...(a)comcast.net>
> wrote:
>
>
>
> > "Keith (Southend)G" <keith_harr...(a)hotmail.com> wrote in message
>
> >news:2d5e108a-193f-46e9-b0d5-d163f51ce54f(a)22g2000yqr.googlegroups.com...
>
> > > 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)
>
> > Sure thing. :-)
>
> > Looks like it should be easy to fix. Everything that's inside the sub
> > Button2_Click needs to go outside of it. Some of the declarations (like
> > Private Const) can't be inside the sub definition, they have to be in the
> > class definition. If you move all of that code out (say, put it after the
> > End Sub) then Button2_Click just needs to look like this:
>
> > Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles Button2.Click
> >     ProcessInput()
> > End Sub
>
> > What will happen then is that, when Button2 is clicked, th ProcessInput sub
> > will be run, which will in turn run the other subs. But all of the subs,
> > functions, and variables declared with Private scope have to be outside of
> > the sub; that way, VB knows where to find them. Right now, VB is seeing
> > those things inside of the sub, and it just doesn't like them to be there.
>
> > --
> > Jack
>
> Something needs to go between End Sub and Private Const?
> Class definition? That's right at the top. Down to 15 errors now.
>
> Keith (Southend)
>
>   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button2.Click
>         ProcessInput()
>     End Sub
>
>     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()


The problems seem to be within here, I have put a cross where error
flag up...

Private Sub ProcessInput()
Dim Reader As New System.IO.StreamReader(InputFile, _

System.Text.Encoding.ASCII)
Dim Writer As New System.IO.StreamWriter(OutputFile, _
,X False,
all textX System.Text.Encoding.ASCII)
Dim InputLine As String = ""
Do
InputLine = GetNextLine(Reader)
If InputLine > "" Then
Dim OutputLine As String = ParseInput(InputLine)
If OutputLine > "" Then
WriterX Writer.WriteLine(OutputLine)
End If
End If
Loop Until InputLine = ""
WriterX Writer.Close()
Reader.Close()
End Sub

I must be trying your patience :-(

Keith (Southend)
From: Captain Jack on
"Keith (Southend)G" <keith_harris9(a)hotmail.com> wrote in message
news:61175d3f-66fc-4998-a668-a1b54f2d157f(a)k17g2000yqh.googlegroups.com...
> I must be trying your patience :-(

No, no, you're fine... I'm having trouble seeing where we're at, at this
point, I'm afraid. Can you repost the whole class, the way you have it now
(without the additional notations)? I'll import it into Visual Studio on my
end, then I can see the actual error messages being generated. If I can see
any changes that need to be made, I'll edit them in, and send the whole
class back.

--
Jack


From: Keith (Southend)G on
On Jan 14, 2:29 pm, "Captain Jack" <CaptainJack1...(a)comcast.net>
wrote:
> "Keith (Southend)G" <keith_harr...(a)hotmail.com> wrote in message
>
> news:61175d3f-66fc-4998-a668-a1b54f2d157f(a)k17g2000yqh.googlegroups.com...
>
> > I must be trying your patience :-(
>
> No, no, you're fine... I'm having trouble seeing where we're at, at this
> point, I'm afraid. Can you repost the whole class, the way you have it now
> (without the additional notations)? I'll import it into Visual Studio on my
> end, then I can see the actual error messages being generated. If I can see
> any changes that need to be made, I'll edit them in, and send the whole
> class back.
>
> --
> Jack


Thanks Jack,

This is how it currently looks from top to tail...

Keith (Southend)

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
ProcessInput()
End Sub

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
From: Captain Jack on
"Keith (Southend)G" <keith_harris9(a)hotmail.com> wrote in message
news:1abadf64-df4d-4b6e-b364-94619253cb1a(a)j24g2000yqa.googlegroups.com...
>
> Thanks Jack,
>
> This is how it currently looks from top to tail...

Ah, I see... I was getting confused because of the way the text gets wrapped
in the messages here. The problem is there are nine lines at the end that
don't belong there, like a fragment of code that didn't get deleted.

I commented out those lines at the end, and the program ran just fine; that
is, clicking on Button2 created the file sorted.txt from the file
ogimet.txt, without any errors.

Just so I don't mess it up, I saved the code out to a text file, and put it
up where you can download it, if you want. The extra lines are still in the
file, I just marked them out as comments so they don't issue an error. I
also deleted a few blank lines, but that didn't make any difference, I just
did that in passing out of habit. You can get this latest version of the
code here:

http://www.CaptainJack3d.com/Code/ogprog.txt

Let me know if you have any trouble with that.

--
Jack