Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

OK, the subject is a little strange, but anyway.

 

I have a custom control that takes user data. But I'm not sure how to wait until user fills his textbox and presses button.

MyControl is placed on Form1.

Ok, here is example code

 

'i'm calling MyControl's GetUser method. It returns True or false.
'the code is located in Form1
If MyControl.GetUser = true
'.....
Else
'......
End if
'............
'***
'........
----------------------------------------------
'ok, and here is code for MyControl's GetUser method
'located in MyControl
Public Functin GetUser() as Boolean

  'here I have to wait until user fills textbox (located on MyControl) and presses button (allso located on MyControl).
  'so, when button is pressed the function shluld continue and return desired value


  If textbox.text <> "Matej" then 
     Return True
  Else
     Return False
  End If

End Function

 

 

OK. I think that my question is quite understandable. I have to stop in the middle of code and wait until the button is pressed. Is it possible?

 

 

tx

 

 

Matej

Edited by mcerk
Posted

there is probably something better than this, but here is something I just thought of

'declare variable at the beginning of program

dim boolWait as boolean

'this goes where you want to wait

boolwait = true

do while boolWait

application.doevents

loop

 

'in the button sub when you press the button

boolWait = false

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi
Posted

I can not call it from Form1 in that case. I have to fire method from Form. The button is, as I said on the control....

 

If I would call it from Form1, Textbox.text value would be in that case "".

 

the problem is, that I do not want the code to continue to '*** (Form1) until user typed his name

 

 

 

Is it possibly to somehow wait in the middle of code and continue when Button_Click event occures? (if a procedure in control stops, code continues to run in the form and goes to '***....)

 

 

 

PS: (see above post for '*** section)

Posted
there is probably something better than this, but here is

'this goes where you want to wait

boolwait = true

do while boolWait

application.doevents

loop

boolWait = false

 

this looks nice, I'm sure it is not only solution, but I can try it.

 

do you know how much resources (cpu, ram) takes this action? is it a lot, or is it not noticable?

 

tx

m

Posted

I know that. But How can I use click event? You have to imagine, that I'm calling control from form1 (let's say from Form_Load).

So I Call method:

MyControl.GetUser (and in the control's aspect of view this is just a function)

so, when this function finishes the code continues to next step (in the form)

 

and that is what I don't want

 

hm. it's hard to actually display it, but I think I did it better on top of the page in the question.

Posted
I can do it by declaring Public Event ReturnValue(AllowLogin as boolean) in the control. And then Fireing it from needed location in the control. I can then catch it in a Form1. But this is not so elegant solution.......
Posted

Ok, but there are similar examples in vb.

if you start Form2 from Form1 by

dim f as new form2

f.show

...the code will continue

 

but if you start it as dialog

f.showdialog then the code stops and continues when form is closed...

 

 

is it possible to do something similar with control?

Posted
A UserControl is part of a form, just like a Button. There's no way to show it modally. If you want to show a modal form then go ahead, otherwise you need to use events. It's exactly the same as it was in VB6
"Who is John Galt?"
  • *Experts*
Posted
Not knowing what your user control is or does, but you can set a Public Properity event that is accessed with the button click and proceed from there.

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...