C
C#14mo ago
ExileWeirdo

❔ need some help with a microsoft visual studio 2022 project im doing

https://dotnetfiddle.net/ got my fiddle here, just nothing aint working and im lost rn
C# Online Compiler | .NET Fiddle
Test your C# code online with .NET Fiddle code editor.
108 Replies
SinFluxx
SinFluxx14mo ago
Unless the mobile app is being weird it looks you've just linked the dotnetfiddle site, not your specific fiddle
ExileWeirdo
ExileWeirdoOP14mo ago
o my bad lemme check
ExileWeirdo
ExileWeirdoOP14mo ago
Sorter | C# Online Compiler | .NET Fiddle
Sorter | Test your C# code online with .NET Fiddle code editor.
ExileWeirdo
ExileWeirdoOP14mo ago
currentrly making some changes i saw that i did things that was unnesecary like declaring a variable in a function when i already have it declared in the namespace
SinFluxx
SinFluxx14mo ago
Are there specific errors you're getting?
ExileWeirdo
ExileWeirdoOP14mo ago
No description
ExileWeirdo
ExileWeirdoOP14mo ago
when i click on sort litterly nothing gets displayed so obviously i did something wrong lmao updated it now
SinFluxx
SinFluxx14mo ago
Have you tried placing a breakpoint so you can run through your code step by step to see what's happening?
ExileWeirdo
ExileWeirdoOP14mo ago
no i have not im rather new to c# and programming general got a few weeks of experience
ExileWeirdo
ExileWeirdoOP14mo ago
No description
ExileWeirdo
ExileWeirdoOP14mo ago
i created the string svar in my Sortering function now but it doesent wanna be useable
ExileWeirdo
ExileWeirdoOP14mo ago
No description
ExileWeirdo
ExileWeirdoOP14mo ago
confusion
SinFluxx
SinFluxx14mo ago
It's fairly straight forward in visual studio you insert a breakpoint at say the first line of the method that should be called when the Sort button is clicked, then run your program, click the Sort button, your code execution will pause and you can then manually proceed line-by-line, see what variables are set to etc to more easily identify issues What does the error for the above say?
ExileWeirdo
ExileWeirdoOP14mo ago
No description
ExileWeirdo
ExileWeirdoOP14mo ago
No description
GaSkia
GaSkia14mo ago
svar is the name of the local variable for the function Sortering so of u haven't created a string for parsing the value that has the same name you just have to add it before the contructor
ExileWeirdo
ExileWeirdoOP14mo ago
wdym im not copying
GaSkia
GaSkia14mo ago
let's proceed step by step
SinFluxx
SinFluxx14mo ago
This one means that you've created the argument string svar for your Sortering method, but the first thing you're doing is setting its value to something else, so there's no pont it being an argument for the method
GaSkia
GaSkia14mo ago
the variable svar what should represent on ur form
ExileWeirdo
ExileWeirdoOP14mo ago
ye yeah but if i set the variable svar within that one and i dont create string svar then i cant use svar in my sort button do i have to put it on the namespace instead? thats what i had from the beginning but i couldnt get any output with it
GaSkia
GaSkia14mo ago
is the function in the same class of svar declaration?
ExileWeirdo
ExileWeirdoOP14mo ago
No description
ExileWeirdo
ExileWeirdoOP14mo ago
im declaring them upo here then ig no theire 2 seperate functions 1 is for sorting the letters and producing an answer and 1 is for what happens when i click the button
GaSkia
GaSkia14mo ago
pass me the file so I can see it entirely
ExileWeirdo
ExileWeirdoOP14mo ago
i want it to 1st tell me the type and in the type and then it will sort them and in the sort it will validate them and then it should produce the answer how do i send the file lmao google drive?
GaSkia
GaSkia14mo ago
yeah also
ExileWeirdo
ExileWeirdoOP14mo ago
its in microsoft visual 2022 so
GaSkia
GaSkia14mo ago
or drag and drop 'em here
ExileWeirdo
ExileWeirdoOP14mo ago
aint working doesent let me drag a folder
GaSkia
GaSkia14mo ago
how many rows?
ExileWeirdo
ExileWeirdoOP14mo ago
dragging all seperate items would be a pain considering theres stuff like bin, obj
ExileWeirdo
ExileWeirdoOP14mo ago
No description
GaSkia
GaSkia14mo ago
only form1.cs have u written in Program.cs?
ExileWeirdo
ExileWeirdoOP14mo ago
ExileWeirdo
ExileWeirdoOP14mo ago
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; namespace prov { internal static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } } this is in program.cs
GaSkia
GaSkia14mo ago
ok where are these?
ExileWeirdo
ExileWeirdoOP14mo ago
wdym like i told u im new to c# and i use microsoft visual 2022, something our school gave us idk man lmao
GaSkia
GaSkia14mo ago
np have u saved the file before sending it? it's a good thing that ur school make you do this projects it's useful in the industry
ExileWeirdo
ExileWeirdoOP14mo ago
i should have
ExileWeirdo
ExileWeirdoOP14mo ago
here u get the designer too
GaSkia
GaSkia14mo ago
can u tell me the line number of this... I have to install the c# compiler... new pc
ExileWeirdo
ExileWeirdoOP14mo ago
No description
GaSkia
GaSkia14mo ago
private void btnSortera_Click(object sender, EventArgs e)
{

TypBestämmning();
Sortering();
lblSorteradData.Text = svar; // you're telling the computer that it needs to store svar into lblSorteradData.Text

}
private void btnSortera_Click(object sender, EventArgs e)
{

TypBestämmning();
Sortering();
lblSorteradData.Text = svar; // you're telling the computer that it needs to store svar into lblSorteradData.Text

}
ExileWeirdo
ExileWeirdoOP14mo ago
didnt work last time cuz it said it didnt recognize svar in the namespace or smt
GaSkia
GaSkia14mo ago
try swapping and send the error
ExileWeirdo
ExileWeirdoOP14mo ago
No description
ExileWeirdo
ExileWeirdoOP14mo ago
the name 'svar' does not excist in the current context
GaSkia
GaSkia14mo ago
svar = lblSorteradData.Text
ExileWeirdo
ExileWeirdoOP14mo ago
thats just wrong tho cuz lblSorteradData.Text is the text in my results
GaSkia
GaSkia14mo ago
okok I see now i'll hop on windows give me two mnis
ExileWeirdo
ExileWeirdoOP14mo ago
sorry for troubling you
SinFluxx
SinFluxx14mo ago
Is validation true when you're clicking the sort button?
ExileWeirdo
ExileWeirdoOP14mo ago
where do i check that
SinFluxx
SinFluxx14mo ago
Well this is where you need to try debugging/setting breakpoints
ExileWeirdo
ExileWeirdoOP14mo ago
yeah im new to c# dont know them
SinFluxx
SinFluxx14mo ago
Well then you need to give it a go If it's false, it looks like the else statement will be hit:
else
{
lblSorteradData.Text = "Error! Fel data!";
}
else
{
lblSorteradData.Text = "Error! Fel data!";
}
Then the btnSortera_Click method will set lblSorteradData.Text = svar straight after, and svar won't have a value at that point
ExileWeirdo
ExileWeirdoOP14mo ago
wdym set lbl = svar
SinFluxx
SinFluxx14mo ago
private void btnSortera_Click(object sender, EventArgs e)
{

TypBestämmning();
Sortering();
lblSorteradData.Text = svar;
}
private void btnSortera_Click(object sender, EventArgs e)
{

TypBestämmning();
Sortering();
lblSorteradData.Text = svar;
}
Here So it would instantly overwrite the error text
ExileWeirdo
ExileWeirdoOP14mo ago
but when i write my else statement shouldnt it just end the programm before i click the button again or am i estupidop
SinFluxx
SinFluxx14mo ago
The else statement will execute, and then execution will return to the method that originally called it
ExileWeirdo
ExileWeirdoOP14mo ago
o what should i put to make it end just return;? or should i do a true or false statement?
SinFluxx
SinFluxx14mo ago
That will still then just return to the original method, you could change your else statement to svar = "Error! Fel data!";
GaSkia
GaSkia14mo ago
maybe I found the solution
ExileWeirdo
ExileWeirdoOP14mo ago
ooo ic what u mean sin
GaSkia
GaSkia14mo ago
go here
No description
GaSkia
GaSkia14mo ago
on the form click on the btn
ExileWeirdo
ExileWeirdoOP14mo ago
ye
GaSkia
GaSkia14mo ago
f4
ExileWeirdo
ExileWeirdoOP14mo ago
ye properties
GaSkia
GaSkia14mo ago
click the thunder btn
ExileWeirdo
ExileWeirdoOP14mo ago
ye actions
GaSkia
GaSkia14mo ago
and look for click and send pic
ExileWeirdo
ExileWeirdoOP14mo ago
wha this entire thing is already a click function
ExileWeirdo
ExileWeirdoOP14mo ago
No description
ExileWeirdo
ExileWeirdoOP14mo ago
btnSortera_Click
GaSkia
GaSkia14mo ago
ok send me a screen of properties-> envents
ExileWeirdo
ExileWeirdoOP14mo ago
dw
GaSkia
GaSkia14mo ago
u said nothing happen when u click so no error neither
ExileWeirdo
ExileWeirdoOP14mo ago
were getting somewhere
ExileWeirdo
ExileWeirdoOP14mo ago
No description
ExileWeirdo
ExileWeirdoOP14mo ago
he had the right solution i fixed the error messages now it gets me error fel data that means its hitting an error message OOO a special one validation isnt working
ExileWeirdo
ExileWeirdoOP14mo ago
No description
ExileWeirdo
ExileWeirdoOP14mo ago
No description
ExileWeirdo
ExileWeirdoOP14mo ago
this is the else if validation isnt true
GaSkia
GaSkia14mo ago
I've lost that conv on reset
ExileWeirdo
ExileWeirdoOP14mo ago
so validation isnt becoming true
SinFluxx
SinFluxx14mo ago
I think the problem is you're not calling ValidationTal() so validation never gets set
ExileWeirdo
ExileWeirdoOP14mo ago
im so kekw
GaSkia
GaSkia14mo ago
got no reference
No description
ExileWeirdo
ExileWeirdoOP14mo ago
i can confirm it is working. i feel like such an idiot haha forgeting to call the function
GaSkia
GaSkia14mo ago
things that happen
ExileWeirdo
ExileWeirdoOP14mo ago
time to error search my answer functions not coming out like i wanted them to
SinFluxx
SinFluxx14mo ago
Indeed, and honestly just have a play around with setting a breakpoint and running your app so that you can try to step through your code one line at a time, it will make things much easier for you to follow, and see things are/aren't happening as you'd expecg
GaSkia
GaSkia14mo ago
u at uni or highschool?
ExileWeirdo
ExileWeirdoOP14mo ago
swedish gymnasium 16 years old. i go to class with 17 year olds tho 1 year younger
GaSkia
GaSkia14mo ago
got it
ExileWeirdo
ExileWeirdoOP14mo ago
im not super into c# etc im more of a web developer but its good to learn incase i need it for frameworks etc or if i wanna combine c# into web
GaSkia
GaSkia14mo ago
u know javascript?
ExileWeirdo
ExileWeirdoOP14mo ago
im a big game fanatic too so 😄 ye javacsript and c# are very similiar
GaSkia
GaSkia14mo ago
yeah
ExileWeirdo
ExileWeirdoOP14mo ago
No description
ExileWeirdo
ExileWeirdoOP14mo ago
ah yes nice sorting weirdo
ExileWeirdo
ExileWeirdoOP14mo ago
No description
ExileWeirdo
ExileWeirdoOP14mo ago
ah yes nice sorting weirdo
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise 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