Post by ivartyn on Feb 6, 2007 17:52:05 GMT
Hi Guys,
Below is a code I've written asking for a user to enter name, address, date of birth, Date Joined.
The date of birth should be validated in the format [dd:mm:yy] and the Date Joined should be validated using format[dd:mm:yyyy]. As you might notice I've tried validating the name and city entry.
Help needed.
SUB adduser
DIM invalidflag AS INTEGER
DIM position AS INTEGER
LET invalidflag = 0
LET position = 0
DO
CLS
CALL heading
OPEN "d:\Project\contact" FOR RANDOM AS #1 LEN = LEN(wdc)
LET totrcno = LOF(1) / LEN(wdc)
LET rcno = totrcno + 1
COLOR 7
PRINT "Member Number : ", rcno
INPUT "Title:(Mr/Mrs/Miss/Prof): ", wdc.title
frst:
LET wdc.frstnme = UCASE$(wdc.frstnme)
COLOR 7: INPUT "First Name : ", wdc.frstnme
IF ASC(wdc.frstnme) < 65 OR ASC(wdc.frstnme) > 90 THEN
COLOR 9: PRINT "Invalid"
PRINT "Must Start with a letter"
LET invalidflag = 1
GOTO frst
END IF
'if asc(mid$(wdc.frstnme,position,1))
COLOR 7
surn:
COLOR 7: INPUT "Last Name : ", wdc.surnme
LET wdc.surnme = UCASE$(wdc.surnme)
IF ASC(wdc.surnme) < 65 OR ASC(wdc.surnme) > 90 THEN
COLOR 9: PRINT "Invalid"
PRINT "Must Start with a letter"
LET invalidflag = 1
GOTO surn
END IF
strt:
INPUT "Street : ", wdc.street
town:
INPUT "City : ", wdc.city
FOR position = 1 TO LEN(wdc.city)
IF ASC(RTRIM$(MID$(wdc.city, position, 1))) < 65 OR ASC(RTRIM$(MID$(wdc.city, position, 1))) > 90 THEN
IF invalidflag = 1 THEN
PRINT "Invalid "
PRINT "Illegal Character at position "; position
ELSE
PRINT "Invalid"
PRINT "Illegal Character at position "; position
LET invalidflag = 1
END IF
END IF
NEXT position
INPUT "Postcode : ", wdc.pcode
INPUT "Date Of Birth[dd:mm:yy] : ", wdc.dob
INPUT "Date Joined[dd:mm:yyyy] : ", wdc.jdate
INPUT "Fees Paid : ", wdc.fees
INPUT "E-mail : ", wdc.email
PRINT : PRINT
PUT #1, rcno, wdc
CLOSE #1
INPUT "Enter Another Member(Y/N): ", reply
LOOP WHILE UCASE$(reply) = "Y"
SLEEP 1
CALL menu
END SUB
Below is a code I've written asking for a user to enter name, address, date of birth, Date Joined.
The date of birth should be validated in the format [dd:mm:yy] and the Date Joined should be validated using format[dd:mm:yyyy]. As you might notice I've tried validating the name and city entry.
Help needed.
SUB adduser
DIM invalidflag AS INTEGER
DIM position AS INTEGER
LET invalidflag = 0
LET position = 0
DO
CLS
CALL heading
OPEN "d:\Project\contact" FOR RANDOM AS #1 LEN = LEN(wdc)
LET totrcno = LOF(1) / LEN(wdc)
LET rcno = totrcno + 1
COLOR 7
PRINT "Member Number : ", rcno
INPUT "Title:(Mr/Mrs/Miss/Prof): ", wdc.title
frst:
LET wdc.frstnme = UCASE$(wdc.frstnme)
COLOR 7: INPUT "First Name : ", wdc.frstnme
IF ASC(wdc.frstnme) < 65 OR ASC(wdc.frstnme) > 90 THEN
COLOR 9: PRINT "Invalid"
PRINT "Must Start with a letter"
LET invalidflag = 1
GOTO frst
END IF
'if asc(mid$(wdc.frstnme,position,1))
COLOR 7
surn:
COLOR 7: INPUT "Last Name : ", wdc.surnme
LET wdc.surnme = UCASE$(wdc.surnme)
IF ASC(wdc.surnme) < 65 OR ASC(wdc.surnme) > 90 THEN
COLOR 9: PRINT "Invalid"
PRINT "Must Start with a letter"
LET invalidflag = 1
GOTO surn
END IF
strt:
INPUT "Street : ", wdc.street
town:
INPUT "City : ", wdc.city
FOR position = 1 TO LEN(wdc.city)
IF ASC(RTRIM$(MID$(wdc.city, position, 1))) < 65 OR ASC(RTRIM$(MID$(wdc.city, position, 1))) > 90 THEN
IF invalidflag = 1 THEN
PRINT "Invalid "
PRINT "Illegal Character at position "; position
ELSE
PRINT "Invalid"
PRINT "Illegal Character at position "; position
LET invalidflag = 1
END IF
END IF
NEXT position
INPUT "Postcode : ", wdc.pcode
INPUT "Date Of Birth[dd:mm:yy] : ", wdc.dob
INPUT "Date Joined[dd:mm:yyyy] : ", wdc.jdate
INPUT "Fees Paid : ", wdc.fees
INPUT "E-mail : ", wdc.email
PRINT : PRINT
PUT #1, rcno, wdc
CLOSE #1
INPUT "Enter Another Member(Y/N): ", reply
LOOP WHILE UCASE$(reply) = "Y"
SLEEP 1
CALL menu
END SUB