I need code in vb 6.0 it is in qb
The following QuickBASIC code will read the employee names and display them on the screen.
Remember to open the .POS file as SHARED in the GLOBAL folder if the Cash Register program is being used over a network.
Code:
COLOR 15, 1: CLS
DIM EMP$(56)
FL$ = "KEYSHOP"
OPEN FL$ + ".POS" FOR RANDOM AS 1 LEN = 80
FOR E = 0 TO 1
FOR A = 1 TO 3: FIELD 1, (A - 1) * 24 AS NULL$, 24 AS E$(A): NEXT
FOR A = 0 TO 9
GET 1, A + 11 + E * 291
FOR B = 1 TO 3
C = A * 3 + B: IF C < 29 THEN EMP$(C + E * 28) = E$(B)
NEXT B, A, E
FOR A = 1 TO 19
FOR B = 0 TO 2
C = A + B * 19
IF C < 57 THEN
LOCATE A, B * 26 + 1
PRINT USING "##.\ \"; C; EMP$(C);
END IF
NEXT B, A
Re: I need code in vb 6.0 it is in qb
This had no responses and had dropped way down on page 2 of ClassicVb so I'm moving it here in the hopes that someone will know enough about QuickBasic to lend a hand.
Re: I need code in vb 6.0 it is in qb
can you post the keyshop.pos file please?
Re: I need code in vb 6.0 it is in qb
Re: I need code in vb 6.0 it is in qb
yeah, post some sort of example of the file to be opened, and explain what the program should do with employee names. im sure someone can help you quite quickly.
Re: I need code in vb 6.0 it is in qb
Ok i am putting line numbers in your code for our easy reference.
Code:
01 COLOR 15, 1: CLS
02 DIM EMP$(56)
03 FL$ = "KEYSHOP"
04 OPEN FL$ + ".POS" FOR RANDOM AS 1 LEN = 80
05 FOR E = 0 TO 1
06 FOR A = 1 TO 3: FIELD 1, (A - 1) * 24 AS 01 NULL$, 24 AS E$(A): NEXT
07 FOR A = 0 TO 9
08 GET 1, A + 11 + E * 291
09 FOR B = 1 TO 3
10 C = A * 3 + B: IF C < 29 THEN EMP$(C + E * 28) = E$(B)
11 NEXT B, A, E
12 FOR A = 1 TO 19
13 FOR B = 0 TO 2
14 C = A + B * 19
15 IF C < 57 THEN
16 LOCATE A, B * 26 + 1
17 PRINT USING "##.\ \"; C; EMP$(C);
18 END IF
19 NEXT B, A
Line 01
This is only for console. In VB6, you have to create a form. A form without any control is equivalent to using CLS in QB.
Lines 02 to 19 except 16 & 17
This will still work because manners of accessing files was only improved -- not changed. Syntax for manipulating variables, arrays are to some extent, remains the same.
Line 16
LOCATE is not supported in VB6. The equivalent is putting a LABEL control in the form created. You can locate that control anywhere in the form at design time. If you want to relocate that at run-time, you just have to manipulate the label's "left" and "top" properties and the values should be in pixel or twips, depending on the form setup. In console, that value is referred to character x,y location.
Line 17
PRINT USING is not supported in VB6. Use the label's caption property instead, to 'print' the desired value and use Format function for that '##.' format.
Something to Add
VB6 is event driven. That means you have to create an event that will trigger Lines 02 to 19 to execute. There are lot's of event that you can use.
I suggest you create a command button as trigger. then select the Click event to create sub/end sub procedure.
The codes in your form would look something like...
Code:
Private Sub Command1_Click()
DIM EMP$(56)
FL$ = "KEYSHOP"
OPEN FL$ + ".POS" FOR RANDOM AS 1 LEN = 80
FOR E = 0 TO 1
FOR A = 1 TO 3: FIELD 1, (A - 1) * 24 AS NULL$, 24 AS E$(A): NEXT
FOR A = 0 TO 9
GET 1, A + 11 + E * 291
FOR B = 1 TO 3
C = A * 3 + B: IF C < 29 THEN EMP$(C + E * 28) = E$(B)
NEXT B, A, E
FOR A = 1 TO 19
FOR B = 0 TO 2
C = A + B * 19
IF C < 57 THEN
Label1.Caption = Format(EMP$(C), "##.")
END IF
NEXT B, A
End Sub
Now, please take note that I did not really check the correctness of your Lines 02 to 19 codes. I dont have copy of your keyshop.pos file and i dont have QB45 anymore. I think the "AS NULL$" in line 06 is misplaced. Just check it at your end. And sorry I already forgot how FIELD work in QB. In VB6, by just looking at it, it will surely generate an error.
Re: I need code in vb 6.0 it is in qb
Quote:
Originally Posted by AioDCS
And sorry I already forgot how FIELD work in QB. In VB6, by just looking at it, it will surely generate an error.
From memory, FIELD [#] device-number, number AS string-variable [, number AS string-variable...]
VB Code:
FOR A = 1 TO 3: FIELD 1, (A - 1) * 24 AS NULL$, 24 AS E$(A)
could be replaced by a UDT.
[Edit: Remembered more]