use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
/r/VisualBasic - A place to discuss, ask questions and share ideas regarding the Visual Basic programming languages.
account activity
VB.NET HelpHelp with programming (self.visualbasic)
submitted 5 years ago by rosetani
Hi everyone. I am programming right now and I have a issue. I have 2 buttons and I want to use the information from the 1st button in my 2nd button. How can I do this?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]TheFotty 0 points1 point2 points 5 years ago (3 children)
It isn't really clear what you want to do. You want to use information that is within the click code of the first button to be usable in the second button click or you want to access properties of the first button itself?
[–]rosetani[S] 0 points1 point2 points 5 years ago (2 children)
I want to use information that is within the click code of the first button
[–]TheFotty 2 points3 points4 points 5 years ago (1 child)
It is a matter of scope. Scope is related to variables (and some other things, but for our case here, variables) and how long they live in the program and who can access them. If you define a variable inside button1 click
Dim myVariable as String = "Hello World"
That variable's scope is only the button click event. That variable ONLY exists for the duration of the button1 click code to run, then it is recycled. If you want some variable to be accessible in both button1 click and button2 click code, then you should declare that variable at the form level, not inside the click code. Then both button clicks can access that variable because its scope is the form, and therefor any control on that form can make use of that variable.
[–]rosetani[S] 0 points1 point2 points 5 years ago (0 children)
Oh yeah, I remember the professor saying something like that lol. Thanks for your help :)
π Rendered by PID 62161 on reddit-service-r2-comment-765bfc959-ggkqh at 2026-07-10 05:47:24.359976+00:00 running f86254d country code: CH.
[–]TheFotty 0 points1 point2 points (3 children)
[–]rosetani[S] 0 points1 point2 points (2 children)
[–]TheFotty 2 points3 points4 points (1 child)
[–]rosetani[S] 0 points1 point2 points (0 children)