Pregunta

I have a form with 5 controls.

For textbox I am accesing like frmNote.txtNumber.Text.

When I am accessing this property directly from form frmNote then I am getting the value of textbox.

But when I created a method for example NewMethod() in different vb file and call this method from frmNote form button click event then I am not able to access frmNote.txtNumber.Text value over there inside method.

It is coming blank. Do I need to pass all control values to method from form or is there any other way around.

¿Fue útil?

Solución

Because txtNumber isn't shared, you can't access it from other class. You must pass it's value to NewMethod. Code will look like this:

Public Sub NewMethod(text as String)
    'Use text
End Sub

And calling NewMethod:

NewMethod(txtNumber.Text)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top