|
-
Jan 5th, 2008, 02:30 AM
#1
Thread Starter
New Member
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
-
Jan 5th, 2008, 04:45 AM
#2
Re: newbie in vb6 hir... help plz
Welcome to the forums. 
What do you want to save it to?
-
Jan 5th, 2008, 07:16 AM
#3
Thread Starter
New Member
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.
-
Jan 5th, 2008, 07:34 AM
#4
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?
-
Jan 5th, 2008, 07:40 AM
#5
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 5th, 2008, 08:25 AM
#6
Thread Starter
New Member
Re: newbie in vb6 hir... help plz
oh yeah your right. saving it is only half the prob.
i guess txt file would suffice.
-
Jan 5th, 2008, 08:29 AM
#7
Hyperactive Member
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?
-
Jan 5th, 2008, 09:06 AM
#8
Thread Starter
New Member
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...
-
Jan 5th, 2008, 12:08 PM
#9
Frenzied Member
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)
-
Jan 5th, 2008, 01:02 PM
#10
Re: newbie in vb6 hir... help plz
This sounds like a school project?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 6th, 2008, 04:33 AM
#11
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.
-
Jan 6th, 2008, 02:45 PM
#12
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
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
|