[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Visual Basic Help

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 14
Thread images: 2

File: 628123_1.jpg (25KB, 480x480px) Image search: [Google]
628123_1.jpg
25KB, 480x480px
How can i call the current button being used?

Got this wall of code being repeated for 30 odd buttons. If i can cut out the butPos7 bit and somehow make it (button that triggered this event) then i can make this all one function. Please help...
>>
File: now.png (20KB, 926x464px) Image search: [Google]
now.png
20KB, 926x464px
And i forgot the picture
>>
>>243724
Goddamnit, actually check back and read the threads you create.

I told you how to do this last time.
>>
>>243727
>>243727 last time was a different problem. This time i'm taking someones advice to not repeat myself and try get a function going
>>
>>243727
but cant as i cant get the current button. Tried button.fromHandles etc etc but doesnt work
>>
>>243729
Nevertheless, I answered your question a day before you asked it.
>>
>>243730
You need to use a "control array".

The way you do this is different depending on which version of VB you're using.
>>
>>243736
You're a genius. Remind me prof. Please
>>
>>243737
is there any way to do it the way i want to. Somehow calling the current events trigger button?
>>
>>243724
>>243739
Simplest way to do this is write one function that uses the "Handles" keyword (http://stackoverflow.com/a/5307257), and store the integer you're looking for in each button's "Tag" property.

Tag is a property that's not used by VB, and is provided to let you store small bits of additional information in objects. You can change the contents of any object's tag in the form editor.

So you'd use something like
sub mybutton_click(byval sender as System.Object ...blahblahblah...) Handles Button1.click, Button2.click, Button3.click...Button40.click
Dim myButton as Button = CType (sender, Button)
Magicnumber = CInt(myButton.Tag)
...blahblahblah...
myButton.backcolor=whatever

and so on.
>>
>>243724
I'm more confused on why people In their freetime decide to learn VB, its a terrible depreciated language on the same level as delphi.
>>
>>243764
>What I wondered was, what happens if you take top-notch C++ programmers who dream in pointers, and let them code in VB. What I discovered at Fog Creek was that they become super-efficient coding machines. The code looks pretty good, it’s object-oriented and robust, but you don’t waste time using tools that are at a level lower than you need. I’ve spent years writing code for C++/MFC and years writing code in Visual Basic, and let me tell you, VB is just much, much more productive.
https://www.joelonsoftware.com/2001/10/17/working-on-citydesk-part-three/
>>
>>243772
>2001
Considering C++ has developed immensely (and accompanying libraries) over the past 15 years most of that blog arguments are hold 0 wieght these days.
VB was superseded with C# anyway.
>>
>>243780
When you write something like Stack Overflow, I'll listen to you instead of Joel Spolsky.
Thread posts: 14
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.