/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
GotFocus and LostFocus!
Fra : Morten Lund


Dato : 14-08-01 16:35

Hi,
I've got a small problem with VB6, I would very much appreciate if anyone
could enlighten me a bit!



The problem can be described as follows;



I got a form with some texfields, checkboxes, datagrids and so on. The
problem is that I've got some code that needs to be run every time for
example a textbox gets focus, but when the focus comes from another textbox
on the same form, it's only "LostFocus"(for the previous textbox.) that is
trickered and not "GotFocus" for the receiving textbox! Does anyone have an
idea why this can be.



In advance thanks.



Morten Lund



 
 
K. P. Olesen (15-08-2001)
Kommentar
Fra : K. P. Olesen


Dato : 15-08-01 17:25

Hi
> [snip] but when the focus comes from another textbox
>on the same form, it's only "LostFocus"(for the previous textbox.) that is
>trickered and not "GotFocus" for the receiving textbox! Does anyone have an
>idea why this can be.
>
I think you are wrong. Both events get trickered. Try making a form
with two textboxes (and f.ex. a command button if you wish). Name the
textboxes "Text1" and "Text2" and enter the code below. Show the
"Intermidiate Window" - its where "Debug.Print" writes. Run the
program and move btw. the textboxes. You will se that lost-focus is
called for the box you are leaving, and then got-focus for the box you
are entering.
So if it is not working - the problem should be elsewhere. Good
luck...

Karl Peder

PS: Wy are we not communicating in Danish in this group???

CODE START:

Private Sub Text1_GotFocus()
Debug.Print "Text1_GotFocus"
End Sub

Private Sub Text1_LostFocus()
Debug.Print "Text1_LostFocus"
End Sub

Private Sub Text2_GotFocus()
Debug.Print "Text2_GotFocus"
End Sub

Private Sub Text2_LostFocus()
Debug.Print "Text2_LostFocus"
End Sub

CODE END...

Søg
Reklame
Statistik
Spørgsmål : 177511
Tips : 31968
Nyheder : 719565
Indlæg : 6408598
Brugere : 218887

Månedens bedste
Årets bedste
Sidste års bedste