Membuat Menu dengan QBasic

Table of Contents

Membuat Menu dengan QBasic

Membuat Menu dengan QBasic

Kode:

DIM menu1(6) AS STRING

menu1(1) = ” < TAMPIL > ”    ‘Mengisi menu
menu1(2) = ” < TAMBAH > ”
menu1(3) = ” < EDIT   > ”
menu1(4) = ” < HAPUS  > ”
menu1(5) = ” < FILTER > ”
menu1(6) = ” < KELUAR > ”

COLOR 1, 3

DO
CLS
COLOR 0, 3

COLOR 14, 4: LOCATE 13, 3: PRINT ”            ”  ‘Tampilan menu
COLOR 14, 4: LOCATE 4, 3: PRINT ” MENU UTAMA ”

FOR i = 1 TO 6
COLOR 1, 2: LOCATE i + 5, 3: PRINT menu1(i)  ‘Mencetak menu
NEXT
COLOR 14, 4: LOCATE 6, 3: PRINT menu1(1)

DIM pil AS INTEGER
pil = 1

DO
key$ = INKEY$
SELECT CASE key$
CASE CHR$(0) + CHR$(80)  ‘Jika menekan panah bawah

COLOR 1, 2: LOCATE pil + 5, 3: PRINT menu1(pil)
IF pil >= 6 THEN
pil = 1
ELSE
pil = pil + 1
END IF
COLOR 14, 4: LOCATE pil + 5, 3: PRINT menu1(pil)

CASE CHR$(0) + CHR$(72)  ‘Jika menekan panah atas

COLOR 1, 2: LOCATE pil + 5, 3: PRINT menu1(pil)
IF pil <= 1 THEN
pil = 6
ELSE
pil = pil – 1
END IF
COLOR 14, 4: LOCATE pil + 5, 3: PRINT menu1(pil)
END SELECT
LOOP UNTIL key$ = CHR$(13)

COLOR 14, 3

SELECT CASE pil    ‘Mengisi perintah jika menu terpilih

CASE 1
LOCATE 3, 19: PRINT “DATA BARANG”
SLEEP 1
CASE 2
LOCATE 3, 19: PRINT “TAMBAH DATA BARANG”
SLEEP 1
CASE 3
LOCATE 3, 19: PRINT “EDIT DATA BARANG”
SLEEP 1
CASE 4
LOCATE 3, 19: PRINT “HAPUS DATA BARANG”
SLEEP 1
CASE 5
LOCATE 3, 19: PRINT “FILTER DATA BARANG”
SLEEP 1
CASE 6
LOCATE 3, 19: PRINT “KELUAR”
END SELECT