12-07-2004, 11:54 AM | #1 | ||
Grizzled Veteran
Join Date: Dec 2002
Location: Little Rock, AR
|
VB Help
I have to write the code for the following for an assignment. The book is no help and every thing I have tried so far does not work. Here is what I have to do:
Create a genreal procedure that displays the current patient. Use the Value property of the scrollbar hsbPNumber as the array subscript to place the patient information into the corresponding text boxes and labels on the form. The name of the objects corresponds to the column, as follows: lblPatientNumber Column 1, value of the scroll bar hsbPNumber txtPatientName Column 2 txtDOB column 3 txtDoctorName Column 4 txtDiagnosis Column 5 txtDateAdmitted Column 6, time the patient was admitted Any ideas?
__________________
Xbox 360 Gamer Tag: GoldenEagle014 |
||
12-07-2004, 12:05 PM | #2 |
Hokie, Hokie, Hokie, Hi
Join Date: Mar 2001
Location: Kennesaw, GA
|
I'm assuming that you're talking about a multi-dimensional array of data, right?
Call PopulateData(patientArray) Function PopulateData(By Ref pData() as Variant) iRow = hsbPNumber.Value lblPatientNumber.caption = iRow txtPatientName = pData(iRow , 2) txtDOB = pData(iRow , 3) txtDoctorName = pData(iRow , 4) txtDiagnosis = pData(iRow , 5) txtDateAdmitted = pData(iRow , 6) End Function Does that work? |
12-07-2004, 12:11 PM | #3 |
Grizzled Veteran
Join Date: Dec 2002
Location: Little Rock, AR
|
Is that for VB.net? I am not getting it to work in VB 6
__________________
Xbox 360 Gamer Tag: GoldenEagle014 |
12-07-2004, 12:19 PM | #4 | |
Hokie, Hokie, Hokie, Hi
Join Date: Mar 2001
Location: Kennesaw, GA
|
Quote:
|
|
12-07-2004, 12:21 PM | #5 |
Grizzled Veteran
Join Date: Dec 2002
Location: Little Rock, AR
|
It highlights Ref and says expected list or separator.
__________________
Xbox 360 Gamer Tag: GoldenEagle014 |
12-07-2004, 12:24 PM | #6 | |
Hokie, Hokie, Hokie, Hi
Join Date: Mar 2001
Location: Kennesaw, GA
|
Quote:
|
|
12-07-2004, 12:26 PM | #7 |
Grizzled Veteran
Join Date: Dec 2002
Location: Little Rock, AR
|
Now when calling the function I get a data mismatch. My Array is defined as varaint.
__________________
Xbox 360 Gamer Tag: GoldenEagle014 |
12-07-2004, 12:28 PM | #8 | |
Hokie, Hokie, Hokie, Hi
Join Date: Mar 2001
Location: Kennesaw, GA
|
Quote:
Dim varArray(1 To 5, 1 To 5) As Variant |
|
12-07-2004, 12:28 PM | #9 |
Pro Rookie
Join Date: Oct 2000
|
Awful nice of VPI to do your homework for you.
|
12-07-2004, 12:31 PM | #10 | |
Grizzled Veteran
Join Date: Dec 2002
Location: Little Rock, AR
|
Quote:
Code:
__________________
Xbox 360 Gamer Tag: GoldenEagle014 Last edited by GoldenEagle : 12-07-2004 at 12:32 PM. |
|
12-07-2004, 12:33 PM | #11 | |
Grizzled Veteran
Join Date: Dec 2002
Location: Little Rock, AR
|
Quote:
Where else can you turn when the book does not answer anyting (this is the wiorst textbox I have ever used) and your professor has cancelled class the past four meetings but still expects you to turn in your homework on time.
__________________
Xbox 360 Gamer Tag: GoldenEagle014 |
|
12-07-2004, 12:36 PM | #12 | |
Grizzled Veteran
Join Date: Dec 2002
Location: Little Rock, AR
|
Quote:
Thx for your comment!
__________________
Xbox 360 Gamer Tag: GoldenEagle014 |
|
12-07-2004, 12:36 PM | #13 | |
Pro Starter
Join Date: Nov 2000
Location: Troy, NY
|
Quote:
Well, you could always find more things to whine about.
__________________
Quis custodiets ipsos custodes? |
|
12-07-2004, 12:36 PM | #14 |
Pro Starter
Join Date: Jul 2001
Location: Not Delaware - hurray!
|
God, I love VB!
__________________
She loves you, yeah, yeah, yeah, yeah! She loves you, yeah! how do you know? how do you know? |
12-07-2004, 12:44 PM | #15 | |
Hokie, Hokie, Hokie, Hi
Join Date: Mar 2001
Location: Kennesaw, GA
|
Quote:
I just tried this out and it worked: Code:
|
|
12-07-2004, 02:00 PM | #16 |
Grizzled Veteran
Join Date: Dec 2002
Location: Little Rock, AR
|
I just went in turned in and the professor told me that he was not going to count in since so many people were having problems with it. That was six hours of my life watsed when I could have studying for my two big finals on Wed.
VPI, thanks for your help. Craig, I hate it. I pefer C++ over VB any day of the week.
__________________
Xbox 360 Gamer Tag: GoldenEagle014 |
12-07-2004, 04:38 PM | #17 |
Pro Starter
Join Date: Jul 2003
Location: South Bend, IN
|
Eh, outside of generics (which are very cool) there's very little that you can do in C++ that is inconvenient to do in VB. It's just a matter of learning the syntax. Part of the problem here is that IMO they're asking you to do something in a suboptimal way. You shouldn't be pulling this data out of an untyped array like that, it's horrid design. You should encapsulate the file processing in one area and then access the data through some kind of interface.
If I were doing something like this, I'd do either a class or module to read the data in and use a class or type to hold it. I wouldn't use a text file for a database, I'd use a real database, probably Access format for a toy problem like this one. Part of the problem with getting the code above to work, I'd imagine, is confusion over variable typing. In the one case, you've got an array of Variants. In the other, you've got a Variant that contains an array. Unfortunately, these are not the same thing. In the full listing, it looks OK, you declare an array of variants and then the sub accepts an array of variants as an argument. If this doesn't work, what error are you getting?
__________________
Hattrick - Brays Bayou FC (70854) / USA III.4 Hockey Arena - Houston Aeros / USA II.1 Thanks to my FOFC Hattrick supporters - Blackout, Brillig, kingfc22, RPI-fan, Rich1033, antbacker, One_to7, ur_land, KevinNU7, and TonyR (PM me if you support me and I've missed you) |
12-07-2004, 05:10 PM | #18 |
Grizzled Veteran
Join Date: Dec 2002
Location: Little Rock, AR
|
I figured it out. It just needed a little tweaking. I agree that the program was very flawed. I was thinking if I was doing this in C++, I would do this and do that. Part of my problem with VB is that I dfo stuff that would work in C++ but not VB. I think its probably best to keep the two seperate.
__________________
Xbox 360 Gamer Tag: GoldenEagle014 |
12-07-2004, 08:32 PM | #19 |
Pro Starter
Join Date: Jul 2003
Location: South Bend, IN
|
It depends what you're trying to do, and what style of C++ you usually program. If you tend more toward procedural and generic style C++, you often won't need to adjust your thinking all that much to work in VB.
__________________
Hattrick - Brays Bayou FC (70854) / USA III.4 Hockey Arena - Houston Aeros / USA II.1 Thanks to my FOFC Hattrick supporters - Blackout, Brillig, kingfc22, RPI-fan, Rich1033, antbacker, One_to7, ur_land, KevinNU7, and TonyR (PM me if you support me and I've missed you) |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|