newbie in vb6 hir... help plz
here's the problem statement:
"You write down people’s birthday on various scraps of paper, on various notepads, and in your pocket calendar. The pieces of paper eventually tend to get lost or misplaced and you do not always carry your pocket calendar, which has incomplete data. Because of this, you miss everyone’s birthdays and have decided to organize the better by building a Visual Basic application. The new application will permit you to view people’s names, birth dates and birth signs by dropping down a list. You further determine that the application should have the capability of adding new data to the existing list. "
i've been able to do almost evrything. the only problem is i don't know how to save the new data in my combobox. meaning, (assuming their are 3 default options in my combobox) and i added a new data to the list then i close the form and re-execute the form, the list should contain 4 datas.
how can i do that? here's my code:
Code:
Dim num As Integer
Private Sub cmdadd_Click()
Combo1.Visible = False
Lblname.Visible = False
lblbday.Visible = False
lblbsign.Visible = False
lblnum.Visible = False
Frame1.Visible = False
Frame2.Visible = False
Frame3.Visible = False
Frame4.Visible = False
cmdadd.Visible = False
cmdadd2.Visible = True
Text1.Visible = True
Text2.Visible = True
Text3.Visible = True
Text4.Visible = True
Label1.Visible = True
Label2.Visible = True
Label3.Visible = True
Label4.Visible = True
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
Private Sub cmdadd2_Click()
If Text1.Text <> "" Then Combo1.AddItem Text1.Text
If Text2.Text <> "" Then Combo2.AddItem Text2.Text
If Text2.Text <> "" Then Combo3.AddItem Text3.Text
If Text2.Text <> "" Then Combo4.AddItem Text4.Text
Combo1.Visible = True
Lblname.Visible = True
lblbday.Visible = True
lblbsign.Visible = True
lblnum.Visible = True
Frame1.Visible = True
Frame2.Visible = True
Frame3.Visible = True
Frame4.Visible = True
cmdadd.Visible = True
cmdadd2.Visible = False
Text1.Visible = False
Text2.Visible = False
Text3.Visible = False
Text4.Visible = False
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
End Sub
Private Sub Combo1_Click()
num = Combo1.ListIndex
Combo2.ListIndex = num
Combo3.ListIndex = num
Combo4.ListIndex = num
Lblname.Caption = Combo1.Text
lblnum.Caption = Combo2.Text
lblbday.Caption = Combo3.Text
lblbsign.Caption = Combo4.Text
End Sub
Re: newbie in vb6 hir... help plz
Welcome to the forums. :wave:
What do you want to save it to?
Re: newbie in vb6 hir... help plz
well the program should retain the added info or data in the combobox list. thats
what i dont know...
if you like to make the program, it will be very much appriciated.
Re: newbie in vb6 hir... help plz
But, how should it retain it.
You have a vareity of options. Which one would you like to employ?
Also, don't forget that saving it is only half the battle.
Once saved, you also have to retrieve it the next time your program runs.
So, how do you want to go?
Database?
Text File?
Excel Spreadsheet?
Something else?
Re: newbie in vb6 hir... help plz
to clarify a little, the above answers
a database is the most efficient for large amounts of data records containing much information,
for a couple of hundred birthdays, a text file is probably quite adequate,
there are other options, but one of those is probably best to start
Re: newbie in vb6 hir... help plz
oh yeah your right. saving it is only half the prob.
i guess txt file would suffice.
Re: newbie in vb6 hir... help plz
Easiest is probably just write the information out to a simple file.
When you close the program, have it write out all the items in the Combobox to the file.
When the program starts the next time, just have it read all the items into the combobox.
Whatever you have now that puts the first three items into the combobox, get rid of. Then make those three items the first items in your outside list.
Do you know how to read/write to an external file?
Re: newbie in vb6 hir... help plz
unfortunately not yet this is my first semester in this subject thats why im still a newbie in this field...
Re: newbie in vb6 hir... help plz
I have a easier code to make the things visible / not visible.
Code:
Function SetVisibility(strName As String, iNum As Integer, blnTF As Boolean)
Dim x As Integer
For x = 1 To iNum
Me.Controls(strName & x).Visible = blnTF
Next
End Function
Function FramesLabelsTexts(blnTF As Boolean)
SetVisibility "Frame", 4, blnTF
SetVisibility "Label", 4, blnTF
SetVisibility "Text", 4, blnTF
End Function
So when you want your Frames, TextBoxes, and Labels visible property to be true you would use:
Call FramesLabelsText (True)
And to set visibility property to false:
Call FramesLabelsText (False)
Re: newbie in vb6 hir... help plz
This sounds like a school project?
Re: newbie in vb6 hir... help plz
Try to do some research first (try to prototype save/load/display of the various options) before deciding which data store to implement... for text files other options are CSV, tab-delimited, INIs and XML. If you have the time, info and sufficient learning curve then try a database.
Re: newbie in vb6 hir... help plz
If you do use a database tehn check out our DAtabase FAQ thread located at the top of the Database Forum. Its a good resource.