473,624 Members | 2,612 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Function call problem

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.EventArg s) 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.GetFileNam eWithoutExtensi on(FullPath)
Location = Path.GetDirecto ryName(FullPath )
MakeReadable(Lo cation, FullPath, BaseName)
End If
End Sub
Function MakeReadable(By Val Location As String, ByVal FullPath As
String, ByVal BaseName As String)
Dim sr As New System.IO.Strea mReader(FullPat h)
Dim oFile As System.IO.File
Dim oWrite As System.IO.Strea mWriter
oWrite = oFile.CreateTex t(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.Substrin g(55, 1)
FrLong = 180000000 + CInt(LineIn.Sub string(191, 9))
FrLat = 90000000 - CInt(LineIn.Sub string(200, 9))
ToLong = 180000000 + CInt(LineIn.Sub string(210, 9))
ToLat = 90000000 - CInt(LineIn.Sub string(219, 9))

'writing new coordinates to new file
oWrite.Write(Fr Long / 1000000)
oWrite.Write(" ")
oWrite.Write(Fr Lat / 1000000)
oWrite.Write(" ")
oWrite.Write(To Long / 1000000)
oWrite.Write(" ")
oWrite.Write(To Lat / 1000000)
oWrite.Write(" ")
'If feType = "A" Then
' oWrite.Write("h wy")
'Else : oWrite.Write("n o")
'End If
oWrite.Write(vb CrLf)
'oWrite.BaseStr eam.Seek(0, SeekOrigin.End)

End While
oWrite.Close()
MessageBox.Show ("Coordinate s written to file")
End Function

Apr 28 '06 #1
7 981
Ataanix,

Why don't you not debug it using the tools.

Set a breakpoint at If OpenFileDialog and see than with clicking at the F11
where it stops.

I hope this helps,

Cor

<at*****@gmail. com> schreef in bericht
news:11******** *************@g 10g2000cwb.goog legroups.com...
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.EventArg s) 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.GetFileNam eWithoutExtensi on(FullPath)
Location = Path.GetDirecto ryName(FullPath )
MakeReadable(Lo cation, FullPath, BaseName)
End If
End Sub
Function MakeReadable(By Val Location As String, ByVal FullPath As
String, ByVal BaseName As String)
Dim sr As New System.IO.Strea mReader(FullPat h)
Dim oFile As System.IO.File
Dim oWrite As System.IO.Strea mWriter
oWrite = oFile.CreateTex t(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.Substrin g(55, 1)
FrLong = 180000000 + CInt(LineIn.Sub string(191, 9))
FrLat = 90000000 - CInt(LineIn.Sub string(200, 9))
ToLong = 180000000 + CInt(LineIn.Sub string(210, 9))
ToLat = 90000000 - CInt(LineIn.Sub string(219, 9))

'writing new coordinates to new file
oWrite.Write(Fr Long / 1000000)
oWrite.Write(" ")
oWrite.Write(Fr Lat / 1000000)
oWrite.Write(" ")
oWrite.Write(To Long / 1000000)
oWrite.Write(" ")
oWrite.Write(To Lat / 1000000)
oWrite.Write(" ")
'If feType = "A" Then
' oWrite.Write("h wy")
'Else : oWrite.Write("n o")
'End If
oWrite.Write(vb CrLf)
'oWrite.BaseStr eam.Seek(0, SeekOrigin.End)

End While
oWrite.Close()
MessageBox.Show ("Coordinate s written to file")
End Function

Apr 28 '06 #2
Cor,
I did but It goes on a loop forever ,and I don't see anything wrong
with the loop.

Apr 28 '06 #3
The least you can tell than where it goes in the loop?

Cor

<at*****@gmail. com> schreef in bericht
news:11******** ************@i3 9g2000cwa.googl egroups.com...
Cor,
I did but It goes on a loop forever ,and I don't see anything wrong
with the loop.

Apr 28 '06 #4
at*****@gmail.c om wrote:
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? <snip> Function MakeReadable(By Val Location As String, ByVal FullPath As
String, ByVal BaseName As String)
Dim sr As New System.IO.Strea mReader(FullPat h) <snip> LineIn = sr.ReadLine() <snip> While sr.Peek <> -1 <snip> End While

<snip>

You must read the line from inside the loop:

While sr.Peek <> -1
LineIn = sr.ReadLine()
'.
'.
'.
End While

Regards,

Branco.

Apr 28 '06 #5
<at*****@gmail. com> schrieb:
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?


Your code is lacking a 'ReadLine' call inside the loop. Check out the
anatomy of line-by-line file reading code here:

Reading a text file line-by-line or blockwise with a progress indicator
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=readfile&la ng=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Apr 28 '06 #6

<at*****@gmail. com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...
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.EventArg s) 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.GetFileNam eWithoutExtensi on(FullPath)
Location = Path.GetDirecto ryName(FullPath )
MakeReadable(Lo cation, FullPath, BaseName)
End If
End Sub
Function MakeReadable(By Val Location As String, ByVal FullPath As
String, ByVal BaseName As String)
Dim sr As New System.IO.Strea mReader(FullPat h)
Dim oFile As System.IO.File
Dim oWrite As System.IO.Strea mWriter
oWrite = oFile.CreateTex t(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.Substrin g(55, 1)
FrLong = 180000000 + CInt(LineIn.Sub string(191, 9))
FrLat = 90000000 - CInt(LineIn.Sub string(200, 9))
ToLong = 180000000 + CInt(LineIn.Sub string(210, 9))
ToLat = 90000000 - CInt(LineIn.Sub string(219, 9))

'writing new coordinates to new file
oWrite.Write(Fr Long / 1000000)
oWrite.Write(" ")
oWrite.Write(Fr Lat / 1000000)
oWrite.Write(" ")
oWrite.Write(To Long / 1000000)
oWrite.Write(" ")
oWrite.Write(To Lat / 1000000)
oWrite.Write(" ")
'If feType = "A" Then
' oWrite.Write("h wy")
'Else : oWrite.Write("n o")
'End If
oWrite.Write(vb CrLf)
'oWrite.BaseStr eam.Seek(0, SeekOrigin.End)

End While
oWrite.Close()
MessageBox.Show ("Coordinate s written to file")
End Function


sr.Peek never consumes the character it reads. It never moves the pointer
from the current location. Inside the loop, you don't have anything that
moves the pointer forward, just peeks...(no readlines, or reads).

Mythran

Apr 28 '06 #7
>> LineIn = sr.ReadLine()

This line needs to be inside your while loop

Apr 28 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
2453
by: Jacek Generowicz | last post by:
I have a program in which I make very good use of a memoizer: def memoize(callable): cache = {} def proxy(*args): try: return cache except KeyError: return cache.setdefault(args, callable(*args)) return proxy which, is functionally equivalent to
3
4790
by: Janross | last post by:
I'm having trouble with a query that's prohibitively slow. On my free-standing office computer it's fine (well, 2-4 seconds), but on the client's network, it takes at least 5 minutes to run. Obviously not workable! I know where the problem is, I just don't know how to fix it. The query calls a function, and I assume it gets slow because the function runs on every record. So--is there a way to rewrite the function so it's quicker?...
9
3267
by: CryptiqueGuy | last post by:
Consider the variadic function with the following prototype: int foo(int num,...); Here 'num' specifies the number of arguments, and assume that all the arguments that should be passed to this function are of type int. (My question has nothing to do with the definition of the function foo, so don't bother about it.) If I call the function as: foo(2,3,4,5,6,7,8);/*More arguments than expected*/
6
5904
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with or without parms. I know that any function that is passed to Eval() must be declared Public. It can be a Sub or Function, as long as it's Public. I even have it where the "function" evaluated by Eval can be in a form (class) module or in a standard...
9
23743
by: Morten Lemvigh | last post by:
Is it possible to pass a pointer to a constructor or a class definition as argument to a function? Maybe in a way similar to passing function pointers...? The function should construct a number of objects using the given constructor. The objects should all inherit from a base class. It's not possible to pass actual objects, since it's not given on beforehand, how many should be created.
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4184
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1489
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.