6 Replies - 734 Views - Last Post: 18 February 2010 - 06:48 AM Rate Topic: -----

#1 slash3584  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 31
  • Joined: 16-December 09

Help on reading and extracting info from a txt file

Posted 17 February 2010 - 08:25 AM

Hello there fellow programmers I just started programming in VB 6 this month, I need help on making an app that can read certain items from txt files with info of a employee (all the txt files have the same format so it's easy to read and there is one txt file for each employee)...the problem is that I need to verify that some items that are checked or unchecked on checkboxes on the user interface are in the txt file... for example there is the Vacation checkbox so if this box is checked I need to find only the employees that are on vacation so I read each employee file and search for the Vacation field to get it's value and if its true I return the name of that employee and add it to a listbox(checking that the name it's not already on the list) so the user can check all the employees that are on vacation... I always end up using like 10 If in a row for each item that needs to be checked. So is there a more precise way to do this?

Any help will be much appreciated! Thanks in advance!

Is This A Good Question/Topic? 0
  • +

Replies To: Help on reading and extracting info from a txt file

#2 guyfromri  Icon User is offline

  • D.I.C Addict

Reputation: 46
  • View blog
  • Posts: 817
  • Joined: 16-September 09

Re: Help on reading and extracting info from a txt file

Posted 17 February 2010 - 08:51 AM

Get Monarch Pro...create the report and program vb to do it that way. VB6 has all the built in OLE codes to run your reports through Monarch against the proper Models with filters. Hope this helps!
Was This Post Helpful? 0
  • +
  • -

#3 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Help on reading and extracting info from a txt file

Posted 17 February 2010 - 08:57 AM

or you can check this snippet
Reading a Text file Line by Line in VB6

good luck dude :)
Was This Post Helpful? 0
  • +
  • -

#4 slash3584  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 31
  • Joined: 16-December 09

Re: Help on reading and extracting info from a txt file

Posted 17 February 2010 - 09:11 AM

I will check Monarch and see how it does... And I forgot to mention that I already can read the files and get the data... the problem is when I want to show the results in the listbox. The code I have now is like:

If cbox1.Value = 1 Then
listbox.AddItem(Name)
End If

And so on for every other item in the txt file... this works when there is only one checkbox on. If there are 2 checked I will have to make an If for every combination of boxes checked and there are like 30 different boxes? xD
Was This Post Helpful? 0
  • +
  • -

#5 guyfromri  Icon User is offline

  • D.I.C Addict

Reputation: 46
  • View blog
  • Posts: 817
  • Joined: 16-September 09

Re: Help on reading and extracting info from a txt file

Posted 17 February 2010 - 09:24 AM

View Postslash3584, on 17 February 2010 - 08:11 AM, said:

I will check Monarch and see how it does... And I forgot to mention that I already can read the files and get the data... the problem is when I want to show the results in the listbox. The code I have now is like:

If cbox1.Value = 1 Then
listbox.AddItem(Name)
End If

And so on for every other item in the txt file... this works when there is only one checkbox on. If there are 2 checked I will have to make an If for every combination of boxes checked and there are like 30 different boxes? xD


In believing that I vaguely follow what you're doing here my response would be try using Cases to cut down on if's. If you use this method correctly, you can use one case to five ifs (rough estimate depending on your output needs)
Was This Post Helpful? 0
  • +
  • -

#6 slash3584  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 31
  • Joined: 16-December 09

Re: Help on reading and extracting info from a txt file

Posted 17 February 2010 - 11:56 AM

What I mean is something like this:

Lets say I have these boxes checked :
Vacation(returns a True boolean if the employee is on vacation)
Male(returns a true boolean if the employee is a male)
Married (returns a true boolean if the employee is married)

When the app finish reading the txt file it will have stored all the items that are evaluated. Then it shows the result the names of the employees that have those characteristics... with one item is easy just a simple:

If chbox1.value = 1 and Marriedbool = True Then

listbox.AddItem(Nameofcurrentemployee)

End If

But if there are 2 checkboxes on I have to make an If with every combination of checkboxes, in this case married-vacation-male, married-male, married-vacation, male-vacation so there will be like a thousand If in the whole code xD
Was This Post Helpful? 0
  • +
  • -

#7 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Help on reading and extracting info from a txt file

Posted 18 February 2010 - 06:48 AM

if it was me i will do the check boxes in array and then check every one of them if it is checked something like this

Dim i As Integer

For i=0 to CheckBox.Count-1
 If CheckBox(i).Value Then
   InputInfo i
 End if
Next i

Private Sub InputInfo(ByVal Index As Integer)
  Select Case Index 
    Case 0 
     'do something like M/F Gander'
    Case 1
     'something elese'
     'etc.....'
  End Select 
End Sub



good luck dude :)

This post has been edited by NoBrain: 18 February 2010 - 07:25 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1