? "Simple Database QStringGrid Demo (Address Book)"
DEFSTR command, filename, name, address, phone
DIM sg AS QSTRINGGRID
sg.ColCount=3
sg.RowCount=1
sg.Separator=","
DO
? "Enter Command:"
INPUT command
SELECT CASE LCASE$(command)
CASE "quit": Application.Terminate
CASE "load"
? "Enter filename: eg. demo.txt"
INPUT filename
sg.loadFromFile(filename,0,0,10000)
CASE "save"
? "Enter filename:"
INPUT filename
sg.SaveTofile(filename,0,0,10000)
CASE "add"
? "Enter Name:"
INPUT name
? "Enter Address:"
INPUT address
? "Enter Phone Number:"
INPUT phone
sg.RowCount=sg.RowCount+1
sg.Cell(0,sg.RowCount-1)=name
sg.Cell(1,sg.RowCount-1)=address
sg.Cell(2,sg.RowCount-1)=phone
CASE "show"
FOR i=1 TO sg.rowCount-1
? "Name: "+sg.Cell(0,i)+" Address: "+sg.Cell(1,i)+"Phone number: "+sg.Cell(2,i)
NEXT
CASE "find"
? "Enter name to retrieve data for:"
INPUT name
FOR i=1 TO sg.rowCount-1
IF INSTR(LCASE$(sg.Cell(0,i)),LCASE$(name)) THEN PRINT "Name: "+sg.Cell(0,i)+" Address: "+sg.Cell(1,i)+" Phone number:"+sg.Cell(2,i)
NEXT
END SELECT
LOOP
|