Tab between the switches in VB6

I have a form consisting of six radio buttons within the frame, which are mutually exclusive and one command button.

I already gave different tabs for each switch, but at runtime, by clicking the focus tab, skipped from the switches.

So how to focus on another switch by pressing TAB?

+6
source share
2 answers
Private Sub Option1_KeyPress(KeyAscii As Integer) If KeyAscii = 9 Then Option2.SetFocus End If End Sub 

KeyAscii = 9 is the code for the Tab key. But you have to do this for all of your switches.

If you add your switches belonging to the same switch having indices 0, 1, 2, you can do it as follows:

 Private Sub Option1_KeyPress(Index As Integer, KeyAscii As Integer) If KeyAscii = 9 Then If Index < Option1.Count - 1 Then Option1(Index + 1).SetFocus Else Option1(0).SetFocus End If End If End Sub 
+2
source

As stated above, this is the intended behavior. If you really want this, then the only way I can do this is to place each switch in a separate image window (BorderStyle = None, TabStop = False). This will work, but you cannot use the arrow keys to move between the switches, only with tabs.

+3
source

Source: https://habr.com/ru/post/919471/


All Articles