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:
- create 2 new
list
variables -dim names new list(of string)
&dim salaries new list(of double)
- read text file line line and, given file format, each line add
salaries
list , every odd line addnames
list - 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:
- create class 2 attributes , whatever other methods need - call
employeedata
, say - create
list of(employeedata)
- loop through text file 2 lines @ time (meaning read in first line, capture name, read in next line, read in salary, loop)
- in each loop, once you've captured data, add new
employeedata
list 2 pieces of captured information. - write small bit of code extract employeedata list salaries or names new list can use bind listbox datasource.
hope makes sense.
Comments
Post a Comment