'===========================================================================
' Subject: MULTIPLE-CHOICE LIST BOX           Date: 08-10-97 (23:49)       
'  Author: L. Jones                           Code: VBDOS                  
'  Origin: ljones@lineone.net               Packet: VB.ABC
'===========================================================================
' Visual basic for DOS multiple-choice list box
'
' This program only works under Visual BASIC for DOS V1
' It will *not* run under QBASIC,QB,GWBASIC, etc.
' You could try it under Visual BASIC for Windows, but Visual Basic
' for Windows from V2 upwards supports multiple choice list boxes ;-)
' I Haven't tried this in Visual BASIC for Windows V1! 
'
' by L Jones, ljones@lineone.net
' 11 August 1997
'
' nb: Does anyone else out there use VBDOS?
'
' This program implements a way of having a multiple-choice list
' box under Visual BASIC for dos. Visual basic for does does not
' support such things but you can 'simulate' the result. The code
' here allows you to click on an item which places a tick beside it.
' Double clicking on one item and then another ticks all items between
' the first and last item (including the first and last items). So double
' clicking on 2 and then double clicking on 5 ticks 2,3,4 and 5.
'
' I Needed a program like this because I am going to try to write a simple
' style of 'SID' file-management program (a la Commodore-Amiga) for the
' PC, and one of the things VBDOS didn't have is multiple choice list
' boxes.
'
' To use this strip off these remarks ('s). Then start off with a new form
' (use the default name "Form1". To it add a fairly small List box (use the
' default name "List1"). Then add the code below.
'
' Apologies for the one and two letter variable names. Normally when I
' make 'experimental' programs like this I sometimes use these names - the
' result of programming on a Commodore 64 long ago (C64 Basic did not
' allow long variable names!). Also apologies for any bugs....
'
' While I am here can anyone at all answer this for me: Can I automatically
' create forms in VBDOS? Or is it completely impossible? What I want to be
' able to do is to, by way of an example, is to (say) click on a button and
' the result would be a new form - but without having to make it in the
' form designer program first. Anyone know how to do this and if it's even
' possible? Thanks!
'
' NB: CHR$(251) is a 'tick' character.
'
' My email address is ljones@lineone.net

' This bit goes in FORM1.FRM
COMMON SHARED t, lo, hi, buttonon

' Just put the numbers 1..25 into the list box for test data..
SUB Form_Load ()
FOR i = 1 TO 25
list1.ADDITEM STR$(i)
NEXT
END SUB

SUB List1_Click ()
IF buttonon = 0 THEN EXIT SUB
a = list1.listindex
a1$ = list1.list(a)
IF MID$(a1$, 1, 1) = CHR$(251) THEN
    a1$ = MID$(a1$, 2, LEN(a1$))
    list1.list(a) = a1$
    EXIT SUB
END IF
a1$ = CHR$(251) + a1$
list1.list(a) = a1$
END SUB

SUB List1_DblClick ()
IF t = 0 THEN lo = list1.listindex: t = 1: EXIT SUB
IF t = 1 THEN
    hi = list1.listindex
    IF lo > hi THEN
        t1 = lo
        t2 = hi
        lo = t2
        hi = t1
    END IF
    t = 0
    FOR a = lo TO hi
    a1$ = list1.list(a)
    IF MID$(a1$, 1, 1) <> CHR$(251) THEN a1$ = CHR$(251) + a1$
    list1.list(a) = a1$
    NEXT
END IF
END SUB

SUB list1_MouseDown (button AS INTEGER, Shift AS INTEGER, X AS SINGLE, Y AS SINGLE)
IF button = 1 THEN buttonon = 1
END SUB

SUB List1_MouseUp (button AS INTEGER, Shift AS INTEGER, X AS SINGLE, Y AS SINGLE)
buttonon = 0
END SUB
