vb.net - Reading Only Words in Text File in Visual Basic -


i'm working on project visual basic class in i'm supposed read in file , display information (employee names , salaries) in list box.

i have total of 4 forms. first form doesn't display anything, has menu items open file, select of other 3 forms, , exit form. in second form (names), employee names read in file displayed in list box. in third form (salaries), employee salaries read in file displayed in list box. fourth form second , displays employee names read in file.

the problem is, don't know how parts of file displayed in list boxes (names , salaries). also, in fourth form have ask user enter amount of months calculate salary selected employee , multiply salary number of months entered user. know how this, except how go getting salary. example, i'm thinking this:

lbltotal.text = dblsalary * intmonths

but don't know how store salary of selected employee in dblsalary variable?

here's code have written far, it's opening open file dialog box when user clicks file->open main form

public class main      private sub openfiletoolstripmenuitem_click(sender object, e eventargs) handles openfiletoolstripmenuitem.click         dim open new openfiledialog         open.filter = "text files |*.txt|all files|*.*"         open.initialdirectory =  environment.getfolderpath(environment.specialfolder.desktopdirectory)     end sub end class 

and here text file titled employees.txt

steve mcgarret   1500.00 danny williams 1300.00 matthew casey 1700.00 kelly severide 1750.00 

i hope that's clear, if not let me know , can try clarify.

thanks in advance.

since homework, won't post specific solution, i'll post idea of how it...

i would:

  1. create 2 new list variables - dim names new list(of string) & dim salaries new list(of double)
  2. read text file line line and, given file format, each line add salaries list , every odd line add names list
  3. set each list datasource appropriate listbox

hope helps , gives idea of how proceed, @ least.

update:

given comment saying wanted store data in class, more along following:

  1. create class 2 attributes , whatever other methods need - call employeedata, say
  2. create list of(employeedata)
  3. loop through text file 2 lines @ time (meaning read in first line, capture name, read in next line, read in salary, loop)
  4. in each loop, once you've captured data, add new employeedata list 2 pieces of captured information.
  5. write small bit of code extract employeedata list salaries or names new list can use bind listbox datasource.

hope makes sense.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -