|
-
Apr 1st, 2010, 06:49 PM
#1
Thread Starter
Member
Load specified Text to listbox
anybody can help me in this.......
in my project i have 2 list box and 2 text box and a textfile
hers the textfile
Code:
[Sunday]
English
10.00
10.30
Maths
11.00
11.30
Economics
12.00
12.30
[Monday]
Accounting
10.00
11.00
Business Studies
12.00
01.30
[Tuesday]
Study skill
10.00
11.30
Management and organization
12.00
01.30
[Wednesday]
Biology
01.00
02.00
Chemistry
02.00
03.30
[Thursday]
Physics
01.00
01.30
[Friday]
Computer Studies
07.00
08.00
[Saturday]
Business Management
11.30
12.45
i want when form load
load all the week days to 1 list box
and when i click on the week day load all the Subjects and when i click on the subject add the 2 time to 2 text box
Here`s a sample Picture
-
Apr 1st, 2010, 06:55 PM
#2
Re: Load specified Text to listbox
Your screen shot looks like you might be using VB.Net. If so, you posted in the wrong forum section.
Other than that, you can search the forums, this question has been asked many many times and there are a lot of examples on how to do it. What you will need to do is load the entire file to one list, then parse the data according to type (If contains "[" then go to list 1, etc...).
EDIT: One more comment, with this, instead of using two listboxes and two text boxes, I would rather choose one Listview with 4 columns (Day, Subjcet, Start Time, End Time) that way all data will be visible at once, you dont have to handle click events for lists to load appropriate data etc.
-
Apr 1st, 2010, 06:57 PM
#3
Re: Load specified Text to listbox
He may be using VB.Net, but this problem can be easily handled in VB6.
-
Apr 1st, 2010, 07:02 PM
#4
Re: Load specified Text to listbox
 Originally Posted by Code Doc
He may be using VB.Net, but this problem can be easily handled in VB6. 
It can be solved with almost any programming language but it still is in the wrong section. People giving him code examples will assume he's using VB6 and give him code that might not work in .Net.
-
Apr 1st, 2010, 07:03 PM
#5
Thread Starter
Member
Re: Load specified Text to listbox
hey guys im using vb6.. not vb.net.. because im using windows 7 it look like im using .net please help me in this
Last edited by manmad; Apr 1st, 2010 at 08:00 PM.
-
Apr 1st, 2010, 08:09 PM
#6
Re: Load specified Text to listbox
 Originally Posted by manmad
hey guys im using vb6.. not vb.net.. because im using windows 7 it look like im using .net please help me in this
I figured as much. Not sure why you were cross-examined in Post #2. VB6 still exists. I use it all the time.
-
Apr 1st, 2010, 08:30 PM
#7
Re: Load specified Text to listbox
He was cross examined because there are some complications with installing VB6 on Vista, and by the look of the theme and his being a novice I asumed he was on .Net. I'm not sure why you are making such a big deal out of it. And, I still use VB6 too.
Anyway, manmad, look at my suggestion in post #2 and let us know if you have any troubles with it.
-
Apr 1st, 2010, 08:38 PM
#8
Re: Load specified Text to listbox
 Originally Posted by baja_yu
He was cross examined because there are some complications with installing VB6 on Vista, and by the look of the theme and his being a novice I asumed he was on .Net. I'm not sure why you are making such a big deal out of it. And, I still use VB6 too.
Anyway, manmad, look at my suggestion in post #2 and let us know if you have any troubles with it.
I'm making a big deal out of it? Good grief.
-
Apr 1st, 2010, 08:39 PM
#9
Re: Load specified Text to listbox
 Originally Posted by manmad
anybody can help me in this.......
in my project i have 2 list box and 2 text box and a textfile
hers the textfile
Code:
[Sunday]
English
10.00
10.30
Maths
11.00
11.30
Economics
12.00
12.30
[Monday]
Accounting
10.00
11.00
Business Studies
12.00
01.30
[Tuesday]
Study skill
10.00
11.30
Management and organization
12.00
01.30
[Wednesday]
Biology
01.00
02.00
Chemistry
02.00
03.30
[Thursday]
Physics
01.00
01.30
[Friday]
Computer Studies
07.00
08.00
[Saturday]
Business Management
11.30
12.45
i want when form load
load all the week days to 1 list box
and when i click on the week day load all the Subjects and when i click on the subject add the 2 time to 2 text box
Here`s a sample Picture

A good place to start : http://www.vbforums.com/showthread.php?t=348141#file
And try using other's suggestion too. If you got stuck at any part, post the code and the details of the error or line that shows the problem.
Good luck
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Apr 1st, 2010, 08:44 PM
#10
Re: Load specified Text to listbox
 Originally Posted by Code Doc
I'm making a big deal out of it?  Good grief. 
Well obviously, because after 3 posts you have yet to post anything useful or relevant to the thread topic, rather than second guessing and commenting on my posts. So... But, now I'm going off topic too so I'm done with the discussion. My suggestions are there, others can take it from here.
-
Apr 2nd, 2010, 12:33 PM
#11
Thread Starter
Member
Re: Load specified Text to listbox
Heres my coding..
Code:
Option Explicit
Private Declare Function GetPrivateProfileSection _
Lib "kernel32" Alias "GetPrivateProfileSectionA" _
(ByVal lpAppName As String, ByVal lpReturnedString As String, _
ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function GetPrivateProfileSectionNames _
Lib "kernel32.dll" Alias "GetPrivateProfileSectionNamesA" _
(ByVal lpszReturnBuffer As String, ByVal nSize As Long, _
ByVal lpFileName As String) As Long
Dim strIniFile As String
Private Sub Form_Load()
Dim arSections() As String
Dim i As Integer
strIniFile = "c:\test.txt"
arSections() = GetSections(strIniFile)
For i = 0 To UBound(arSections)
List1.AddItem arSections(i)
Next i
If List1.ListCount > 0 Then List1.ListIndex = 0
End Sub
Private Sub List1_Click()
Dim arValues() As String
Dim i As Integer
List2.Clear
arValues() = GetValues(strIniFile, List1.List(List1.ListIndex))
For i = 0 To UBound(arValues)
List2.AddItem arValues(i)
Next i
End Sub
Public Function GetSections(inifile As String) As String()
Dim strBuffer As String
Dim arSections() As String
Dim lngLength As Long
strBuffer = String$(1024, 0)
lngLength = GetPrivateProfileSectionNames(strBuffer, 1024, inifile)
strBuffer = Left$(strBuffer, lngLength)
arSections = Split(strBuffer, vbNullChar)
GetSections = arSections()
End Function
Public Function GetValues(inifile As String, sectionname As String) As String()
Dim strBuffer As String
Dim bufLength As Long
Dim arValues() As String
Dim lngLength As Long
bufLength = 10240
strBuffer = String$(bufLength, 0)
lngLength = GetPrivateProfileSection(sectionname, strBuffer, bufLength, inifile)
strBuffer = Left$(strBuffer, lngLength)
arValues = Split(strBuffer, vbNullChar)
GetValues = arValues()
End Function
in this coding i can load the week days to 1 listbox and the subjects to the 2nd listbox.. bt i dnt knw how can i load the starting time and end time to the textboxes can u put somehelp on it.....
-
Apr 2nd, 2010, 12:42 PM
#12
Re: Load specified Text to listbox
Is the file format a given or can you modify it? If you can, I'd suggest doing something like this
[Monday]
SubjectCount=2
Name1=Maths
Start1=10:00
End1=11:00
Name2=English
Start2=11:00
End2=12:00
That way you can use all INI manipulation functions to load data. First grab the count, then do a For Loop (1 To Count) and grab each value "Name" & I, "Start" & I, "End" & I (I from the For Loop counter).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|