❔ need help with visual studio community

hi i have multipul q 1- i have mac is there way to have community on it 2- please hoe to make 3 button each one show diffrente pic when click on it
102 Replies
hercules_x_x
hercules_x_xOP2y ago
visual studio 2022 community*
Pobiega
Pobiega2y ago
1: No. There is something called "Visual Studio for Mac" but its a very very different product. I'd suggest JetBrains Rider for Mac development. Your other option is visual studio code (or another LSP editor). 2: That sounds like a UI thing. If you are on Mac, that means both WPF and WinForms is unavailable to you, so are you using Avalonia or something like MAUI?
hercules_x_x
hercules_x_xOP2y ago
i am using parallel
Pobiega
Pobiega2y ago
Thats the virtualization thing where you run windows apps right?
hercules_x_x
hercules_x_xOP2y ago
which is i have laggy stupid windows11 but it do for now
Pobiega
Pobiega2y ago
In that case, you might be able to use VS Community
hercules_x_x
hercules_x_xOP2y ago
until i buy laptop yes already 😦 but....very laggy ahhh but the uni insisted on it
Pobiega
Pobiega2y ago
well, its a virtualization tool.
hercules_x_x
hercules_x_xOP2y ago
what can i do
Pobiega
Pobiega2y ago
Not sure I follow. You can either use VS Community, or you can't. Its a very binary option :p
hercules_x_x
hercules_x_xOP2y ago
so for the button u have ny idea how
Pobiega
Pobiega2y ago
You need to provide more info
hercules_x_x
hercules_x_xOP2y ago
yes i can
Pobiega
Pobiega2y ago
What UI framework are you using?
hercules_x_x
hercules_x_xOP2y ago
winform app ,net .net
Pobiega
Pobiega2y ago
okay. Then the easiest way is to make a picturebox and 3 buttons
hercules_x_x
hercules_x_xOP2y ago
then
Pobiega
Pobiega2y ago
then in the OnClick handler for each button, you set the picturebox image to something different
hercules_x_x
hercules_x_xOP2y ago
i dont understand the last part i try to put 3 pic and 3 button but when i run debug the pic apears too lol all
Pobiega
Pobiega2y ago
Sure, you could have 3 pictureboxes and just toggle their visibility on/off as appropriate that works too
hercules_x_x
hercules_x_xOP2y ago
how can u teach me please
Pobiega
Pobiega2y ago
start with all hidden, and make button 1 show box 1 and hide box 2 and 3 Not really. I don't have visual studio installed, so I can't make winforms apps 😛
hercules_x_x
hercules_x_xOP2y ago
hahaha that sad how about the cod anyidea code
Pobiega
Pobiega2y ago
I mean, its near trivial
public class Form1
{
public void Button1_Click(object sender)
{
pictureBox1.Visible = true;
pictureBox2.Visibile = false;
pictureBox3.Visibile = false;
}
}
public class Form1
{
public void Button1_Click(object sender)
{
pictureBox1.Visible = true;
pictureBox2.Visibile = false;
pictureBox3.Visibile = false;
}
}
repeat as needed, and dont forget to wire up the events
hercules_x_x
hercules_x_xOP2y ago
so this need to be repeated to the three buttons
Pobiega
Pobiega2y ago
yes. once for each button
hercules_x_x
hercules_x_xOP2y ago
what u mean the events? ok that understand but events?
Pobiega
Pobiega2y ago
well, the clicking of a button doesnt do anything unless you have set up the events in the editor, when you click on a button, it creates the event mapping and an empty method for youi so just do that for all 3 buttons
hercules_x_x
hercules_x_xOP2y ago
ohhhhh that always automatic been genrated thats why i didnt understand u really good damn there is one more thing hehe hmm i also actually dont understand i dont know how to ask even Create a form as follows. When each button is pressed, the amount of coins is added to the total sum displayed. When the Clear button is pressed, the total resets to zero (0.0). wht in the devil name is this
hercules_x_x
hercules_x_xOP2y ago
Pobiega
Pobiega2y ago
easy.
hercules_x_x
hercules_x_xOP2y ago
i search every where for an answer dont have
Pobiega
Pobiega2y ago
well, you probably searched for an answer to exactly that problem
hercules_x_x
hercules_x_xOP2y ago
are u sure
Pobiega
Pobiega2y ago
but what you need is the generic solution to "how do I do something when a button is pressed"
hercules_x_x
hercules_x_xOP2y ago
OhNo
Pobiega
Pobiega2y ago
so, you have 6 buttons here. 5 coin buttons and a clear button
hercules_x_x
hercules_x_xOP2y ago
aha may i know why passed ?
Pobiega
Pobiega2y ago
?
hercules_x_x
hercules_x_xOP2y ago
i mean the term u use quite intresting ok never mind i ma listing
Pobiega
Pobiega2y ago
Well if you slow down one sec and think about it this is not a hard problem, is it?
hercules_x_x
hercules_x_xOP2y ago
coin buttons?
Pobiega
Pobiega2y ago
Pobiega
Pobiega2y ago
coin buttons.
Pobiega
Pobiega2y ago
Pobiega
Pobiega2y ago
makes sense to me to call them coin buttons
hercules_x_x
hercules_x_xOP2y ago
ohhhh got u so its an add proceces Process* so ok can i do q 1 first please dont go ya 10 minuts i back
Pobiega
Pobiega2y ago
?
hercules_x_x
hercules_x_xOP2y ago
ok q1 for the pic i did it just now amazing man thank u soo much q 2 is the coin one i am confuse with coding only
Pobiega
Pobiega2y ago
okay, so lets break it down a bit all the coin buttons do the same thing but with a different value. what is the thing that it does?
hercules_x_x
hercules_x_xOP2y ago
ok ok
Pobiega
Pobiega2y ago
break it down in simple steps
hercules_x_x
hercules_x_xOP2y ago
its add i think like keep adding value
Pobiega
Pobiega2y ago
I'd say it does at least 2 things 1: add the value to some counter 2: update the UI
hercules_x_x
hercules_x_xOP2y ago
ohh yeah update i forgot otherwise cant see the new value
Pobiega
Pobiega2y ago
exactly so, how would you go about coding that?
hercules_x_x
hercules_x_xOP2y ago
hahaha lost already ok ok adding ez but update i cant
Pobiega
Pobiega2y ago
update is easy too its just textbox1.Text = yourCounter.ToString();
hercules_x_x
hercules_x_xOP2y ago
why tostring()
Pobiega
Pobiega2y ago
because your counter is a numeric type otherwise adding to it wont work as expected but textboxes only operate on strings
hercules_x_x
hercules_x_xOP2y ago
if not numeric? also this goes in the coin button isit is it
Pobiega
Pobiega2y ago
sure. I'd probably make a helper method thou
hercules_x_x
hercules_x_xOP2y ago
so each one will make an update
Pobiega
Pobiega2y ago
since all your coinbuttons do the same thing, except for value so why not have a AddAndUpdate(int) method
hercules_x_x
hercules_x_xOP2y ago
lost already ohh this is relace for this one textbox1.Text = yourCounter.ToString(); replace
Pobiega
Pobiega2y ago
not entirely
hercules_x_x
hercules_x_xOP2y ago
then i am trying to squize my brain but feel lost sorry
Pobiega
Pobiega2y ago
well, you COULD do this:
public class Form1
{
private TextBox textbox1 = new TextBox();
private decimal money = 0;

public void Button1_Click()
{
money += 50;
textbox1.Text = money.ToString();
}

public void Button2_Click()
{
money += 20;
textbox1.Text = money.ToString();
}
}
public class Form1
{
private TextBox textbox1 = new TextBox();
private decimal money = 0;

public void Button1_Click()
{
money += 50;
textbox1.Text = money.ToString();
}

public void Button2_Click()
{
money += 20;
textbox1.Text = money.ToString();
}
}
but thats silly
hercules_x_x
hercules_x_xOP2y ago
why u said silly
Pobiega
Pobiega2y ago
because it is
public class Form1
{
private TextBox textbox1 = new TextBox();
private decimal money = 0;

private void AddMoney(decimal amount)
{
money += amount;
textbox1.Text = money.ToString();
}

public void Button1_Click()
{
AddMoney(50);
}

public void Button2_Click()
{
AddMoney(20);
}
}
public class Form1
{
private TextBox textbox1 = new TextBox();
private decimal money = 0;

private void AddMoney(decimal amount)
{
money += amount;
textbox1.Text = money.ToString();
}

public void Button1_Click()
{
AddMoney(50);
}

public void Button2_Click()
{
AddMoney(20);
}
}
when you can do this why would I specify my update logic each time, when I can write a helper method and only do it once?
hercules_x_x
hercules_x_xOP2y ago
ok wait a second can i equest sometjing something can u explain helper method
Pobiega
Pobiega2y ago
its just a method
hercules_x_x
hercules_x_xOP2y ago
or its time consuming for u
Pobiega
Pobiega2y ago
you can make your own methods. its sort of what programming is 99% about :p
hercules_x_x
hercules_x_xOP2y ago
ok so u call it that lol let me run this give me few minuits
Pobiega
Pobiega2y ago
yeah. this is a "helper" in that it just does the thing I want the others to do, but in a generic unified way
hercules_x_x
hercules_x_xOP2y ago
yes i got u hmm how to do the clear button lolo lol the one reset everything just type end ?
Pobiega
Pobiega2y ago
I mean, that should be very easy, no? what should the clear button do, do you think?
hercules_x_x
hercules_x_xOP2y ago
sorry i was doing the coins button i would say reset
Pobiega
Pobiega2y ago
and if you were to break that down?
hercules_x_x
hercules_x_xOP2y ago
end end program ahh dont known
Pobiega
Pobiega2y ago
why end program? the instructions dont say anything about that
hercules_x_x
hercules_x_xOP2y ago
i am sure its command word in coding but i was thinking reseat lol Resetting
Pobiega
Pobiega2y ago
lets say you are storing your money in a decimal money; variable how would you reset that?
hercules_x_x
hercules_x_xOP2y ago
public void Button1_Click() { textbox1.Text = reset.ToString(); } i will put them all inside reset all
Pobiega
Pobiega2y ago
how would that work? what is reset? also, you need to actually reset your money variable...
hercules_x_x
hercules_x_xOP2y ago
when i try the cod upove it show errer
hercules_x_x
hercules_x_xOP2y ago
i really dont know private TextBox textbox1 = new TextBox(); private decimal money = 0; i cant type this it show erreo error
Pobiega
Pobiega2y ago
that wasnt part of the code like I said, i dont have VS installed
hercules_x_x
hercules_x_xOP2y ago
hercules_x_x
hercules_x_xOP2y ago
all good but that error only
Pobiega
Pobiega2y ago
no
hercules_x_x
hercules_x_xOP2y ago
hercules_x_x
hercules_x_xOP2y ago
not working lol
Pobiega
Pobiega2y ago
dont just copy paste my code, understand what each line does
hercules_x_x
hercules_x_xOP2y ago
that zero i add believe me i am trying i give up it rreally cant
hercules_x_x
hercules_x_xOP2y ago
what to put here please 😦
hercules_x_x
hercules_x_xOP2y ago
need constructor i thing i think
Pobiega
Pobiega2y ago
you shouldnt have that textchanged handler at all so remove that its saying AddMoney doesnt exist, so add it
hercules_x_x
hercules_x_xOP2y ago
hi sorry i had an emergency ok so i will re satrt bececuas if i delet domething in the code its all glitch up something busy ? 😦
Pobiega
Pobiega2y ago
I see no question.
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server