A
ataanis
Hey everyone
I'm writing this simple function call from a sub , but for some reason
when I click the file to open, it freezes, can anybody tell me what's
the deal?
Thanks
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuItem2.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Dim FullPath As String
Dim BaseName As String
Dim Location As String
FullPath = OpenFileDialog1.FileName
BaseName = Path.GetFileNameWithoutExtension(FullPath)
Location = Path.GetDirectoryName(FullPath)
MakeReadable(Location, FullPath, BaseName)
End If
End Sub
Function MakeReadable(ByVal Location As String, ByVal FullPath As
String, ByVal BaseName As String)
Dim sr As New System.IO.StreamReader(FullPath)
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
oWrite = oFile.CreateText(Location + "\" + BaseName + ".txt")
Dim LineIn As String
LineIn = sr.ReadLine()
Dim FrLong As Integer
Dim FrLat As Integer
Dim ToLong As Integer
Dim ToLat As Integer
Dim feFirP As String
Dim feName As String
Dim feType As String
Dim feDirS As String
Dim tlId As Long
Dim version As Short
Dim side1 As Boolean
Dim cfcc As String
While sr.Peek <> -1
'Converting coordinates
feType = LineIn.Substring(55, 1)
FrLong = 180000000 + CInt(LineIn.Substring(191, 9))
FrLat = 90000000 - CInt(LineIn.Substring(200, 9))
ToLong = 180000000 + CInt(LineIn.Substring(210, 9))
ToLat = 90000000 - CInt(LineIn.Substring(219, 9))
'writing new coordinates to new file
oWrite.Write(FrLong / 1000000)
oWrite.Write(" ")
oWrite.Write(FrLat / 1000000)
oWrite.Write(" ")
oWrite.Write(ToLong / 1000000)
oWrite.Write(" ")
oWrite.Write(ToLat / 1000000)
oWrite.Write(" ")
'If feType = "A" Then
' oWrite.Write("hwy")
'Else : oWrite.Write("no")
'End If
oWrite.Write(vbCrLf)
'oWrite.BaseStream.Seek(0, SeekOrigin.End)
End While
oWrite.Close()
MessageBox.Show("Coordinates written to file")
End Function
I'm writing this simple function call from a sub , but for some reason
when I click the file to open, it freezes, can anybody tell me what's
the deal?
Thanks
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuItem2.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Dim FullPath As String
Dim BaseName As String
Dim Location As String
FullPath = OpenFileDialog1.FileName
BaseName = Path.GetFileNameWithoutExtension(FullPath)
Location = Path.GetDirectoryName(FullPath)
MakeReadable(Location, FullPath, BaseName)
End If
End Sub
Function MakeReadable(ByVal Location As String, ByVal FullPath As
String, ByVal BaseName As String)
Dim sr As New System.IO.StreamReader(FullPath)
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
oWrite = oFile.CreateText(Location + "\" + BaseName + ".txt")
Dim LineIn As String
LineIn = sr.ReadLine()
Dim FrLong As Integer
Dim FrLat As Integer
Dim ToLong As Integer
Dim ToLat As Integer
Dim feFirP As String
Dim feName As String
Dim feType As String
Dim feDirS As String
Dim tlId As Long
Dim version As Short
Dim side1 As Boolean
Dim cfcc As String
While sr.Peek <> -1
'Converting coordinates
feType = LineIn.Substring(55, 1)
FrLong = 180000000 + CInt(LineIn.Substring(191, 9))
FrLat = 90000000 - CInt(LineIn.Substring(200, 9))
ToLong = 180000000 + CInt(LineIn.Substring(210, 9))
ToLat = 90000000 - CInt(LineIn.Substring(219, 9))
'writing new coordinates to new file
oWrite.Write(FrLong / 1000000)
oWrite.Write(" ")
oWrite.Write(FrLat / 1000000)
oWrite.Write(" ")
oWrite.Write(ToLong / 1000000)
oWrite.Write(" ")
oWrite.Write(ToLat / 1000000)
oWrite.Write(" ")
'If feType = "A" Then
' oWrite.Write("hwy")
'Else : oWrite.Write("no")
'End If
oWrite.Write(vbCrLf)
'oWrite.BaseStream.Seek(0, SeekOrigin.End)
End While
oWrite.Close()
MessageBox.Show("Coordinates written to file")
End Function