04-09-2024, 12:44 AM
Code: (Select All)
'Let's start with the easiest way to print and view multiple screens of data.
'The solution here, is, of course, to simply pause at each screen so you can view it.
For i = 1 To 100
Print i
If i Mod 20 = 0 Then 'here is a simple check to see if the number divided by 20 has a remainder of 0.
Print "Press <ANY KEY> to continue." 'some simple feedback for the user to know what to do.
Sleep 'here's the pause after those 20 items and feedback are printed to the screen
Cls 'and after the user hits a key, we'll clear the screen and print the next 20 items
End If
Next
'Now, with that very simple method out of the way, let's go a step further and make an actual scrollable list.
'For starters, we have to have a list which we can scroll.
'I'll create that here with an array, just like above.
Dim My_List(1 To 100) As String 'an array to hold the list of 100 items.
For i = 100 To 1 Step -1 'a loop to put data into the array.
My_List(101 - i) = Str$(i) + " bottles of beer on the wall, then stuff..." 'my cheesy demo list
Next
'Now that we have a list, let's work on displaying it.
_KeyClear 'clear the keyboard buffer so those SLEEP inputs have no chance of affecting anything
Do 'you'll want a loop so you can have the user feedback for scrolling up or down
Cls 'clear the screen
If start < 1 Then start = 1 'our list starts with a minimum of item #1
If start > 100 Then start = 100 'and goes up to a maximum of item #100
finish = start + 20 'we can display at most 20 items on our screen
If finish > 100 Then finish = 100 'can't display more items than what we have on the screen!
For i = start To finish 'a loop to print the items we've chosen from our starting point to our end point.
Print My_List(i)
Next
Print
Print "Press <U>p or <D>own to scroll the list, or <Q>uit." 'instructions for our user control
User_choice$ = Input$(1) 'Get the user input
Select Case User_choice$ 'decide what to do with the user input
Case "U", "u": start = start - 1 'scroll up an item
Case "D", "d": start = start + 1 'scroll down an item
Case "Q", "q": System 'quite
End Select
Loop 'and we're basically finished with this scrolling loop!
A very simple demo with comments to help explain what everything is doing along the way. If Terry thinks it fits his tutorial, he's more than welcome to make use of it as he sees fit. Feel free to modify, expand, edit, whatever, as you need it.