Multiple screens

I have a dictionary like:

[code] dim lDict as new Dictionary

lDict.Value(11) = “0100100000”
lDict.Value(12) = “0000100000”
lDict.Value(13) = “0000110000”
lDict.value(14) = “0101100000”
lDict.Value(15) = “0101100000”
lDict.Value(16) = “0101100000”
lDict.Value(17) = “1101111100”
[/code]

Each string represents a certain screenPanel which is presented or not to the user; I have 10 screens, if a position is a “1” the screen is shown, otherwise it is omitted.

On the panels there are 2 Buttons "Next"and “Previous”. If the user clicks “Next”, the following screen must be shown, in case there is a “1” in that position, if there is a “0” try the next position etc. Clicking “Previous” should reverse this mechanism.

I can’t get it to work properly. Maybe it is the weather (36C today in Holland), I don’t know. I’m stuck in limbo… Who can help me out?

What does the keys 11, 12, 13… represent?

The keys represent an index, built from multiple choice questions. An index with value 12 represents a first choice on question 1 and a second choice on question 2… I use it as an unique identifier.

Do you only navigate through one string with the prev/next buttons, e.g. “0100100000”, after the user made multiple choice selections?

Just trying to puzzle together how the multiple choice indexes relates to the strings.

Yes, I have a global var that corresponds with the position in the string.

like

dim logicString as String = ldict.value(13) //gives you entry 13 screenPosition = screenPosition + 1 screenToShow = mid(logicString,screenPosition,1)

I can test
do
if screenToShow = 0 or 1
in case 1 show screen number Screenposition
in case 0 next screen
loop

I can do this in a loop, but the problem there is that the loop does not wait for the screen to be shown, it loops in milliseconds, that is one of the problems. The screen is shown via a Panel.Value = xx

Perhaps this code might help you?

[code] Dim screenConfig As String
Dim ch As String
Dim screenPosition As Integer

screenConfig = “0100100000”
screenPosition = -1

’ -------- get next screen start -------------

do
screenPosition = screenPosition + 1
ch = Mid(screenConfig, screenPosition, 1)
loop until (ch = “1”) or (screenPosition >= Len(screenConfig))
if ch <> “1” then
screenPosition = Len(screenConfig) + 1
end if

’ -------- get next screen end -------------

if (screenPosition <= Len(screenConfig) then
’ do something with screenPosition
end if[/code]

What does the loop accomplish here, and where should you put this code in?

You’d probably put everything between the start and end lines, in your Next button’s action event.

The code moves from the current screen position (screenPosition), to the next screen position that is set to “1”.

ScreenConfig is just a test string I’ve created, and will probably be the value that you get from your dictionary.

OK, many thanks, I’ll try this in half an hour or so. Get back to you…

Great stuff. I haven’t really tested it, but it should do the job. Let me know if you have any questions.

Ok,

I think I understand. Where to put the code for the actual screen change (i.e. windowPanel.Value = 6)?

I think the code should look like this…

windowPanel.Value = screenPosition

This instruction should probably be the last instruction in your Next button’s action event.

The action event handler of your “Next” button?

[code]do
screenPosition = screenPosition + 1
ch = Mid(screenConfig, screenPosition, 1)
loop until (ch = “1”) or (screenPosition >= Len(screenConfig))
if ch <> “1” then
screenPosition = Len(screenConfig) + 1
end if

windowPanel.Value = screenPosition
[/code]

Sorry, correction (I couldn’t edit my post):

do 
  screenPosition = screenPosition + 1
  ch = Mid(screenConfig, screenPosition, 1)
  if ch = "1" then
    windowPanel.Value = screenPosition
  end if
loop until (ch = "1") or (screenPosition >= Len(screenConfig))

and to reverse I have to decrement the screenPosition

do screenPosition = screenPosition -1 ch = Mid(screenConfig, screenPosition, 1) if ch = "1" then windowPanel.Value = screenPosition end if loop until (ch = "1") or (screenPosition < 0)

Yes, the boundary check just needs to be

(screenPosition <= 0)

though.

Did the code work for the next button?

Actually, I think it should be

(screenPosition <= 1)

Yep… you’re right I guess, ‘off by one’

Now testing…

Actually… it does work! Kudos…