Qbasicnews.com

Full Version: Hey Agamemnus!!!!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9
Is that program you helped me on in records????....Just wondering thanks man
that depends on what you mean.

If you mean "record = a bunch of data for X amount of people", then yes..
For future reference. Questions such as this should be sent as a private message. if you don't know what that is, there is a button at the bottom of that users post that say "PM", that will automatically bring to the message writing screen.
Yea thats what im talking about Aga....Thanks....Ok i understand mech1031
However, I suspect that your teacher may have told you something about this:

TYPE
END TYPE

and thought TYPEs were "records"?
Yea we have to do that....Iv started on it....Ill post the code later and show you where im at cus i am kinda stuck but gotta run right now talk to u later
Ok, types are almost the same as just having arrays, except instead of:

array1.x(i%)

You do:

array1(i%).x
Quote:However, I suspect that your teacher may have told you something about this:

TYPE
END TYPE

and thought TYPEs were "records"?

In fact, in QB, TYPEs are records. In other languages such as C you can define any kind of data structure using user defined types, but in QB this is limited only to structures with records.
To me, a set of arrays could be a record.

A record is also a music/sound format that's like a CD but 3 times larger and played with one of those needle thingos.

How do you define a record?
Heres the code im stuck on

Code:
DECLARE SUB Information ()
DECLARE SUB Sort ()
'DECLARE SUB Printing ()

DIM SHARED sort.item%
DIM SHARED entry.amount%
DIM SHARED gender.type$(1 TO 2)
DIM SHARED Nme$(1 TO 11)
DIM SHARED Address$(1 TO 11)
DIM SHARED Id(1 TO 11) AS LONG
DIM SHARED gender%(1 TO 11)
DIM SHARED Payrate(1 TO 11)

TYPE ClassRecord
Nme AS STRING * 15
Address AS STRING * 38
Id AS INTEGER
gender AS STRING * 2
Payrate AS SINGLE
END TYPE

DIM Info(1 TO 11) AS ClassRecord

CLS
PRINT "Choose how you want to sort the items!"
PRINT "--------------------------------------"
PRINT
PRINT "By name          Press 1"
PRINT "By address       Press 2"
PRINT "By id            Press 3"
PRINT "By gender        Press 4"
PRINT "By payrate       Press 5"
INPUT "Which do you want to sort by"; sort.item%
'PRINT
'PRINT "Type screen to print on screen, type printer to print from printer."
'PRINT "-------------------------------------------------------------------"
'INPUT "Do you want to print on screen or print on printer"; print$

gender.type$(1) = "Male"
gender.type$(2) = "Female"

CALL Information
CALL Sort
'CALL Printing

CLS

FOR i% = 1 TO 11
PRINT "Name: "; Nme$(i%);
SLEEP 1
PRINT " Address: "; Address$(i%)
PRINT "ID: "; Id(i%)
PRINT "Gender: "; gender.type$(gender%(i%))
PRINT "Hourly Salary: $"; Payrate(i%)
PRINT
NEXT i%

SUB Information

Nme$(1) =
Nme$(2) =
Nme$(3) =
Nme$(4) =
Nme$(5) =
Nme$(6) =
Nme$(7) =
Nme$(8) =
Nme$(9) =
Nme$(10) =
Nme$(11) =

Address$(1) =
Address$(2) =
Address$(3) =
Address$(4) =
Address$(5) =
Address$(6) =
Address$(7) =
Address$(8) =
Address$(9) =
Address$(10) =
Address$(11) =

Id(1) =
Id(2) =
Id(3) =
Id(4) =
Id(5) =
Id(6) =
Id(7) =
Id(8) =
Id(9) =
Id(10) =
Id(11) =

gender%(1) = 1
gender%(2) = 1
gender%(3) = 1
gender%(4) = 1
gender%(5) = 1
gender%(6) = 1
gender%(7) = 1
gender%(8) = 1
gender%(9) = 1
gender%(10) = 2
gender%(11) = 2

Payrate(1) = 6.3
Payrate(2) = 8.13
Payrate(3) = 8
Payrate(4) = 9.5
Payrate(5) = 7.35
Payrate(6) = 8.2
Payrate(7) = 6.95
Payrate(8) = 7.46
Payrate(9) = 6.25
Payrate(10) = 8.51
Payrate(11) = 6

END SUB

SUB Printing

'IF print$ = "Screen" OR print$ = "screen" THEN
    'FOR i% = 1 TO 11
    'PRINT "Name: "; name$(i%);
    'SLEEP 1
    'PRINT " Address: "; address$(i%)
    'PRINT "ID: "; id(i%)
    'PRINT "Gender: "; gender.type$(gender%(i%))
    'PRINT "Hourly Salary: $"; hourlysalary(i%)
    'PRINT
    'NEXT i%
'ELSE
    'FOR i% = 1 TO 11
    'LPRINT "Name: "; name$(i%);
    'SLEEP 1
    'LPRINT " Address: "; address$(i%)
    'LPRINT "ID: "; id(i%)
    'LPRINT "Gender: "; gender.type$(gender%(i%))
    'LPRINT "Hourly Salary: $"; hourlysalary(i%)
    'LPRINT
    'LPRINT
    'NEXT i%
'END IF

END SUB

SUB Sort

SELECT CASE sort.item%
CASE 1
    FOR i% = 1 TO 11
    FOR j% = 1 TO i%
    IF Nme$(j%) > Nme$(i%) THEN
    SWAP Nme$(j%), Nme$(i%)
    SWAP Address$(j%), Address$(i%)
    SWAP Id(j%), Id(i%)
    SWAP gender%(j%), gender%(i%)
    SWAP Payrate(j%), Payrate(i%)
    END IF
    NEXT j%, i%

CASE 2
    FOR i% = 1 TO 11
    FOR j% = 1 TO i%
    IF Address$(j%) > Address$(i%) THEN
    SWAP Nme$(j%), Nme$(i%)
    SWAP Address$(j%), Address$(i%)
    SWAP Id(j%), Id(i%)
    SWAP gender%(j%), gender%(i%)
    SWAP Payrate(j%), Payrate(i%)
    END IF
    NEXT j%, i%

CASE 3
    FOR i% = 1 TO 11
    FOR j% = 1 TO i%
    IF Id(j%) > Id(i%) THEN
    SWAP Nme$(j%), Nme$(i%)
    SWAP Address$(j%), Address$(i%)
    SWAP Id(j%), Id(i%)
    SWAP gender%(j%), gender%(i%)
    SWAP Payrate(j%), Payrate(i%)
    END IF
    NEXT j%, i%

CASE 4
    FOR i% = 1 TO 11
    FOR j% = 1 TO i%
    IF gender%(j%) > gender%(i%) THEN
    SWAP Nme$(j%), Nme$(i%)
    SWAP Address$(j%), Address$(i%)
    SWAP Id(j%), Id(i%)
    SWAP gender%(j%), gender%(i%)
    SWAP Payrate(j%), Payrate(i%)
    END IF
    NEXT j%, i%

CASE 5
    FOR i% = 1 TO 11
    FOR j% = 1 TO i%
    IF Payrate(j%) > Payrate(i%) THEN
    SWAP Nme$(j%), Nme$(i%)
    SWAP Address$(j%), Address$(i%)
    SWAP Id(j%), Id(i%)
    SWAP gender%(j%), gender%(i%)
    SWAP Payrate(j%), Payrate(i%)
    END IF
    NEXT j%, i%
END SELECT
END SUB
Pages: 1 2 3 4 5 6 7 8 9