Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net
Go Back  Xtreme Visual Basic Talk > > > Problems with searching in a .dat file in .Net


Reply
 
Thread Tools Display Modes
  #1  
Old 01-14-2004, 04:23 AM
NeilB NeilB is offline
Freshman
 
Join Date: Nov 2003
Location: England
Posts: 35
Unhappy Problems with searching in a .dat file in .Net


I am currently having a problem searching for a customer's name in a .dat file. Every time I enter the day and the customers name the program stops.

Please help me

Code:
Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click '============================================================= '== Sub: btnsearch_Click(...) '== Descript: Searches for a customer '== Dim CustomerName As String Dim found As Boolean = False Dim inputstream As StreamReader Dim dayName As String Dim line As String Dim words(3) As String Dim Ok As Boolean CustomerName = InputBox("Please enter Customers name", "Please enter Customers name") dayName = InputBox("Enter day name (Monday, Tuesday, etc)") If CustomerName = "" Then MessageBox.Show("Please enter a valid Name") Else Ok = LoadFile(dayName) line = inputstream.ReadLine() While (line <> Nothing) And found = False words = Split(line, ",") If Trim(words(0)) = CustomerName Then MessageBox.Show("The Customers name is" & CustomerName) found = True Else line = inputstream.ReadLine() End If End While If Not found Then MessageBox.Show(CustomerName & "not found") End If inputstream.Close() End If
Reply With Quote
  #2  
Old 01-14-2004, 06:33 AM
Iceplug's Avatar
IceplugProblems with searching in a .dat file in .Net Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Does execution just stop when you are in this button?
I don't see where you are creating the file for the inputstream to read.

Or maybe it's not finding the customer's name.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 01-14-2004, 07:00 AM
NeilB NeilB is offline
Freshman
 
Join Date: Nov 2003
Location: England
Posts: 35
Default

Yup it only stops when using this button, it goes to -
Code:
Line = inputstream.ReadLine()
and cuts out.

The file has already been created from another button on the form. It is loaded when the person enteres the date into the inputbox before they enter the name and this selects the file.
Reply With Quote
  #4  
Old 01-14-2004, 07:12 AM
Iceplug's Avatar
IceplugProblems with searching in a .dat file in .Net Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

But the thing is that you have declared another one for use in this subroutine, and that's not the one that you've made in the other button.
Dim inputstream As StreamReader
You need to declare that in the Form Class outside of the methods.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #5  
Old 01-14-2004, 12:43 PM
NeilB NeilB is offline
Freshman
 
Join Date: Nov 2003
Location: England
Posts: 35
Default

Sorry I'm afraid you have lost me, God why can't VB.net be more like VB6!!!
Reply With Quote
  #6  
Old 01-14-2004, 12:53 PM
reboot's Avatar
rebootProblems with searching in a .dat file in .Net reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,614
Default

If you want VB6, use VB6.
Reply With Quote
  #7  
Old 01-14-2004, 03:06 PM
NeilB NeilB is offline
Freshman
 
Join Date: Nov 2003
Location: England
Posts: 35
Default

I'm sorry but was there any need for that? All I asked was a simple question not be be told to **** off and use summat else.
Reply With Quote
  #8  
Old 01-14-2004, 03:43 PM
reboot's Avatar
rebootProblems with searching in a .dat file in .Net reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,614
Default

I'm still stuck doing mostly VB6, and *I* find myself saying "God why can't VB6 be more like vb.Net". *shrug*

Don't be so easily offended.
Reply With Quote
  #9  
Old 01-14-2004, 05:06 PM
Iceplug's Avatar
IceplugProblems with searching in a .dat file in .Net Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Quote:
Originally Posted by NeilB
Sorry I'm afraid you have lost me, God why can't VB.net be more like VB6!!!


Actually, the concept of scope exists in VB6 as well, so it's not a .NET thing .
Code:
Dim Y As Integer 'Variable 1 Private Sub Command1_Click() Dim X As Integer 'Variable 2 Y = 4000 'sets Variable 1 X = 400 'sets variable 2 End Sub Private Sub Command2_Click() Dim X As Integer 'Variable 3 Y = 2000 'Variable 1 X = 200 'Variable 3 - there is no way to access Variable 2 from 'a procedure other than Command1_Click. End Sub
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #10  
Old 01-15-2004, 11:50 AM
Machaira's Avatar
MachairaProblems with searching in a .dat file in .Net Machaira is offline
Jedi Coder

* Expert *
 
Join Date: Aug 2002
Location: Abingdon, MD
Posts: 3,438
Default

It looks like if you change:

Ok = LoadFile(dayName)

to:

inputstream = New StreamReader(dayName)

you'll be ok.
Reply With Quote
  #11  
Old 01-16-2004, 10:04 AM
NeilB NeilB is offline
Freshman
 
Join Date: Nov 2003
Location: England
Posts: 35
Default

Thanks for the help, I've got it to work
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
File I/O GavinO Tutors' Corner 5 04-17-2013 02:18 PM
Installation Problem - PLs help urgenlty dpdsouza Installation / Documentation 4 12-02-2004 08:09 PM
File Problems: Files Not Closing etc. Templeton Peck General 5 03-30-2003 12:34 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net
 
Problems with searching in a .dat file in .Net
Problems with searching in a .dat file in .Net
 
-->