473,473 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

bad file name or number

3 New Member
Hi all,

M using visual basic 2005. I have declared a variable Log_File as integer in a module.

I've open a file using openfile in a function (which is again defined in the same module). M using a Print function to write inot the file. When i call Print function within same moude it works fine. But if i call Print from a event in form, i m gettin bad ile name or number exception.

Can anyone help me. Wat m i missin her?

Thanks in advance
Virendra Chaudhary
Mar 1 '07 #1
6 4716
willakawill
1,646 Top Contributor
Hi Virendra. Post your code please. The part that works and the part that does not work. Then we will work out the problem together.
Thanks
Mar 1 '07 #2
cvirendra
3 New Member
Hi Virendra. Post your code please. The part that works and the part that does not work. Then we will work out the problem together.
Thanks
Thankx for d reply...

the code dat works is

Expand|Select|Wrap|Line Numbers
  1. Public Sub processSend(ByVal message As String, ByVal port As String)
  2.         System.Threading.Thread.Sleep(50)
  3.         My.Forms.frmMain.serialPort.Write(message & vbCrLf)
  4.         Last_Sent_Time = GetTickCount()
  5.         Print(Log_File, Last_Sent_Time & "@" & message & vbCrLf)
  6. End Sub
I m callin dis function whenever I hv a data to b sent 2 d serial port. Also this function is defined in a module.

Now on the frmMain form I have a serialport control. On the recieve event i hv written d followin code..

Expand|Select|Wrap|Line Numbers
  1. Private Sub serialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles serialPort.DataReceived
  2.  
  3.         Dim ReceiveTimeStamp As Long
  4.  
  5.         ReceiveTimeStamp = GetTickCount()
  6.  
  7.         If (Look_Buffer_Count >= 19) Then
  8.             Look_Buffer_Count = 0
  9.         Else
  10.             Look_Buffer_Count = Look_Buffer_Count + 1
  11.         End If
  12.  
  13.  
  14.         Look_Buffer(Look_Buffer_Count) = ReceiveTimeStamp & "@" & Me.serialPort.ReadLine
  15.  
  16.         If (Start_Logging = True) Then
  17.             'Call updateLogFile(ReceiveTimeStamp & "@" & Look_Buffer(Look_Buffer_Count))
  18.             Print(Log_File, Look_Buffer(Look_Buffer_Count))
  19.         End If
  20. End Sub
Here while executin line "Print(Log_file......" i get bad file name or number exception.

Hope dis clear d problem 2 u.
Mar 1 '07 #3
Killer42
8,435 Recognized Expert Expert
Have you checked what the value is in Log_File when it works, and when it doesn't?
Mar 1 '07 #4
cvirendra
3 New Member
Have you checked what the value is in Log_File when it works, and when it doesn't?
Yes! It is the same both d times ...
Mar 1 '07 #5
Killer42
8,435 Recognized Expert Expert
Yes! It is the same both times ...
Damn! :(

Not being familiar with VB.Net, I'm pretty much out of ideas.
Mar 1 '07 #6
willakawill
1,646 Top Contributor
Yes! It is the same both d times ...
That does not make sense. Either the file has been closed, not opened yet, or out of scope. We need to know the scope of Log_File and where and when it is given a file handle.
Mar 1 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Jeff Wagner | last post by:
I am importing a file which contains a persons name (firstName, middleName, etc). If I define a function to do this, how can I use the variables outside of that function? Here is the code: ...
11
by: Ignacio X. Domínguez | last post by:
Hi. I'm developing a desktop application that needs to store some data in a local file. Let's say for example that I want to have an address book with names and phone numbers in a file. I would...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
1
by: j7.henry | last post by:
I am trying to pull specific data that is in a comma delimited file into a web page. So if my comma delimited file looks like: Name,Address,Zip Fred,123 Elm,66666 Mike,23 Jump,11111 I would...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
13
by: swetha | last post by:
HI Every1, I have a problem in reading a binary file. Actually i want a C program which reads in the data from a file which is in binary format and i want to update values in it. The file...
4
by: rsaharia | last post by:
Hello All, I need help with this particular .pl file I picked up from http://www.veritools-usa.com/xnf2vhdl.htm What it's supposed to do is really convert an xnf file to a vhdl file. I need it for...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.