문제

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.

도움이 되었습니까?

해결책

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top