|
|
#1 |
|
Member
Join Date: Jan 07
Posts: 32
![]() |
Ok, here are the details... I've spent hours trying to code this simple program but it refuses to work... I am completely new to this and am starting to think that i'm a little too stupid to learn vb..
1) This is a hotel reservation system and the hotel name is constant. Let say Hilton. 2) Initially, the program will contain 10 guest names already. I tried using array but I've no idea what to do next.. 3) The program then asks for the names and will validate them before the guests will be able to book a room. Error will be generated when the name is wrongly inserted and the thing will loop over and over asking for reentry of name. (Here.. I tried using the "do while.. loop" but it doesn't recognise my array) 4) The guests will then have to choose between 10 rooms and an error will be generated if the rooms were booked already. (How is this even possible? Do I just pick a random rooms as full already or is there a proper way?) Again, the thing will ask for another room and loops. 5) Finally, all the details about one guest's booking (the one that "log in") will be displayed. Do I use picturebox for this? As an additional note, how, do I use subprograms and parameter passing in this? I've read the vb for dummies book but I still am clueless... I just don't understand the concept of parameter passing or subprograms. I will really appreciate it if anyone can help a newbie here. If possible, don't give explanations that are too hard to follow since I've asked my friend who works in the IT industry and he suggested that I use access to store the guest details... lol.. I only need a simple program... I know I've been rambling for a bit.. sorry! Thanks! |
|
|
|
|
|
#2 |
|
Terrible Member
Join Date: Aug 06
Location: United States
Posts: 2,822
![]() ![]() |
Re: New to VB 6! Can't code this program.. :(
Welcome to vbf!If this is a School assignment, then we cannot help you write the program, we wont write the whole program any way. We will only help with specific questions... Have you thought about using a Database? |
|
|
|
|
|
#3 |
|
Member
Join Date: Jan 07
Posts: 32
![]() |
Re: New to VB 6! Can't code this program.. :(
Nah, i don't expect you guys to write the code, more like point me at the right direction..
For the array I tried and use.. Dim guest(10) as string Guest(0) = name1 Guest(1) = name 2 and so on.. The problem comes when I tried to do the do..while loop.. valid = InputBox("Who are you?") Do While valid <> guest(10) -----> It won't recognise this..why? valid = InputBox("reenter") Loop |
|
|
|
|
|
#4 |
|
Terrible Member
Join Date: Aug 06
Location: United States
Posts: 2,822
![]() ![]() |
Re: New to VB 6! Can't code this program.. :(
I am not good with arrays, but i am guessing that dimming "guest(10)" is not proper.
Try this: VB Code:
And use [vbcode ] [ /vbcode] tags |
|
|
|
|
|
#5 |
|
Addicted Member
Join Date: Dec 05
Posts: 226
![]() |
Re: New to VB 6! Can't code this program.. :(
I guess it's because dim guest(10) = start from 0 ...9
so 10 is not valid |
|
|
|
|
|
#6 |
|
Super Moderator
Join Date: Jul 02
Location: Bristol, UK
Posts: 27,113
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: New to VB 6! Can't code this program.. :(
The array declaration is fine, and by definition there is an element 10 (the number in the Dim line is not the amount of items, but the index of the last item).
vert, try to be very specific about the problems you are having... dclamp and Vntalk have assumed that you are getting an error message pop up, but I dont think you are - I think it just isn't working as you want it to. As you currently have it, you are only comparing to one of the guests ( guest(10) ), instead of checking if it is any of them. To do that you need to use a loop. I would recommend looking at this FAQ thread which explains about arrays, and how to use them. (you will probably find other useful info in our Classic VB FAQ's, link below).
__________________
Classic VB FAQs (updated Jun 6th) ...Database Development FAQs/Tutorials (updated Mar 26th) (includes fixing common VB errors) .......... (includes fixing common DB related errors, and [Classic VB] ADO tutorial /further steps, and [VB.Net] ADO.Net Tutorial). Tutorial: How to automate Excel from VB6 (or VB5/VBA) .•. SQL 'Select' statement formatter/checker .•. Convert colour number to colour name .•. FlexGrid: fill from recordset .•. FlexGrid: AutoSize columns .•. DB Reserved Words checker Connection strings .•. MDAC/Jet/ACE downloads .•. SQL Server downloads .•. MZTools (free upgrade for the VB6/VBA Editor) |
|
|
|
|
|
#7 |
|
Member
Join Date: Jan 07
Posts: 32
![]() |
Re: New to VB 6! Can't code this program.. :(
Oh, I thought by using ( guest(10) ), or 9 perhaps, I will be comparing it from 0-9..all at once...
That page seems very helpful... but I still don't understand it.. how do you include every array in the input validation? it's about 12 am now so im going to go.. I will update on my progress tomorrow... Last edited by vert; Jan 21st, 2007 at 07:17 PM. |
|
|
|
|
|
#8 | |
|
Terrible Member
Join Date: Aug 06
Location: United States
Posts: 2,822
![]() ![]() |
Re: New to VB 6! Can't code this program.. :(
Quote:
|
|
|
|
|
|
|
#9 |
|
PowerPoster
Join Date: Jun 01
Location: Trafalgar, IN
Posts: 2,470
![]() ![]() ![]() |
Re: New to VB 6! Can't code this program.. :(
See if this gets you going in the right direction
VB Code:
|
|
|
|
|
|
#10 |
|
PowerPoster
Join Date: May 06
Location: Location, location!
Posts: 2,526
![]() ![]() |
Re: New to VB 6! Can't code this program.. :(
There have been suggestions made in the past about ways to quick-search an array. If the array is fixed, my suggestion has always been to set up a string with each entry in it and a * on either side of the name...as in "*Vert*dclamp*vntalk*si_the_geek*MarkT*"...then when you are checking for a name you instr for "*" & name & "*" and it should return 0 if the name isn't in there. Downside to that is it doesn't return the location (so you will only know it is a valid name, not which one in the array is that name). It's a lot of work for a simple bit of code though, and if you want to go the easy way then a loop would be the better option.
I'd go with a simple loop in this case :-)
__________________
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects Expect more to come in future If I have helped you, RATE ME! :-) I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words! And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful. |
|
|
|
|
|
#11 |
|
PowerPoster
Join Date: Feb 06
Location: East of NYC, USA
Posts: 5,692
![]() ![]() ![]() ![]() |
Re: New to VB 6! Can't code this program.. :(
When addressing an array it's always better to use LBound(ArrayName) and UBound(ArrayName) as the lower and upper element numbers. That way, if you have to change the number of elements in the array you won't have to go through your code changing every occurrence of the lower or upper element number.
__________________
The most difficult part of developing a program is understanding the problem. The second most difficult part is deciding how you're going to solve the problem. Actually writing the program (translating your solution into some computer language) is the easiest part. Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana |
|
|
|
|
|
#12 | |
|
Member
Join Date: Jan 07
Posts: 32
![]() |
Re: New to VB 6! Can't code this program.. :(
Quote:
I think this will be enough to start me off. Last edited by vert; Jan 22nd, 2007 at 03:13 PM. |
|
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|