Results 1 to 8 of 8

Thread: Why .setfocus is not running every time?

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2011
    Posts
    110

    Post Why .setfocus is not running every time?

    In a form, I have a listbox, a textbox, a spinbutton and a button "finish". I created the spinbutton to goes through the listbox and I use the textbox to save values to each property on listbox usin a array MyMtx().

    It's almost working:

    Code:
    Private Sub SpinButton1_Change()
        
        If SpinButton1.Value > ListBox1.ListCount Then
            SpinButton1.Value = ListBox1.ListCount
        End If
        
        If ListBox1.ListCount > SpinButton1.Value And SpinButton1.Value >= 0 And SpinButton1.Value <= ListBox1.ListCount Then
            ListBox1.ListIndex = SpinButton1.Value
        End If
        TextBox1.SetFocus
        
    End Sub
    and
    Code:
    Private Sub ListBox1_Change()
        SpinButton1.Value = ListBox1.ListIndex
        TextBox1.Text = MyMtx(ListBox1.ListIndex, 2)
        TextBox1.SetFocus
    End Sub
    Code:
    Private Sub TextBox1_Change()
    On Error Resume Next
        MyMtx(ListBox1.ListIndex, 2) = TextBox1.Text
    End Sub
    The spinbutton is working, it can run through the listbox Up and Down, perfect. But, TextBox1.SetFocus is not working. I don't know why, it works just each two times I click on spinbutton, not every time I click.
    Last edited by marlonsaveri; Jul 19th, 2011 at 03:25 PM. Reason: To put [Code] on 3rd code.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width