Membuat Sub Program Hapus Data di Quick Basic (QBasic)

Posted by

Source code program dibawah ini adalah lanjutan dari program Operasi File di Qbasic, pada tulisan kali ini saya mempostingkan Sub Procedure HapusData, Berikut Source Code nya :

SUB hapusdata

COLOR 0, 10
CLS

DIM hapus AS INTEGER
jmlrec = LOF(1) / LEN(siswa)

OPEN "c:\sun2.txt" FOR RANDOM AS #2 LEN = LEN(siswa)

CALL kotak(2, 2, 15, 40, 7, 1, 0)
LOCATE 4, 3: INPUT "Masukan Nim :", cari$

SEEK #1, 1
FOR i = 1 TO jmlrec
GET #1, i, siswa
IF RTRIM$(siswa.nim) <> RTRIM$(cari$) THEN
PUT #2, i, siswa
ELSE
EXIT FOR
END IF
NEXT i

FOR j = i + 1 TO jmlrec
GET #1, j, siswa
PUT #2, j - 1, siswa
NEXT

CLOSE #1
CLOSE #2
KILL "c:\sun.txt"
NAME "c:\sun2.txt" AS "c:\sun.txt"
OPEN "c:\sun.txt" FOR RANDOM AS #1 LEN = LEN(siswa)
PRINT "data terhapus"
x$ = INPUT$(1)

CALL tampildata '==>ini memanggil Procedure TampilData


END SUB

semoga bermanfaat...


FOLLOW and JOIN to Get Update!

Social Media Widget SM Widgets




Demo Blog NJW V2 Updated at: 8:40 PM