C
C#9mo 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
SinFluxx9mo ago
Unless the mobile app is being weird it looks you've just linked the dotnetfiddle site, not your specific fiddle
ExileWeirdo
ExileWeirdo9mo ago
o my bad lemme check
ExileWeirdo
ExileWeirdo9mo ago
Sorter | C# Online Compiler | .NET Fiddle
Sorter | Test your C# code online with .NET Fiddle code editor.
ExileWeirdo
ExileWeirdo9mo 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
SinFluxx9mo ago
Are there specific errors you're getting?
ExileWeirdo
ExileWeirdo9mo ago
No description
ExileWeirdo
ExileWeirdo9mo ago
when i click on sort litterly nothing gets displayed so obviously i did something wrong lmao updated it now
SinFluxx
SinFluxx9mo ago
Have you tried placing a breakpoint so you can run through your code step by step to see what's happening?
ExileWeirdo
ExileWeirdo9mo ago
no i have not im rather new to c# and programming general got a few weeks of experience
ExileWeirdo
ExileWeirdo9mo ago
No description
ExileWeirdo
ExileWeirdo9mo ago
i created the string svar in my Sortering function now but it doesent wanna be useable
ExileWeirdo
ExileWeirdo9mo ago
No description
ExileWeirdo
ExileWeirdo9mo ago
confusion
SinFluxx
SinFluxx9mo 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
ExileWeirdo9mo ago
No description
ExileWeirdo
ExileWeirdo9mo ago
No description
GaSkia
GaSkia9mo 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
ExileWeirdo9mo ago
wdym im not copying
GaSkia
GaSkia9mo ago
let's proceed step by step
SinFluxx
SinFluxx9mo 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
GaSkia9mo ago
the variable svar what should represent on ur form
ExileWeirdo
ExileWeirdo9mo 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
GaSkia9mo ago
is the function in the same class of svar declaration?
ExileWeirdo
ExileWeirdo9mo ago
No description
ExileWeirdo
ExileWeirdo9mo 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
GaSkia9mo ago
pass me the file so I can see it entirely
ExileWeirdo
ExileWeirdo9mo 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
GaSkia9mo ago
yeah also
ExileWeirdo
ExileWeirdo9mo ago
its in microsoft visual 2022 so
GaSkia
GaSkia9mo ago
or drag and drop 'em here
ExileWeirdo
ExileWeirdo9mo ago
aint working doesent let me drag a folder
GaSkia
GaSkia9mo ago
how many rows?
ExileWeirdo
ExileWeirdo9mo ago
dragging all seperate items would be a pain considering theres stuff like bin, obj
ExileWeirdo
ExileWeirdo9mo ago
No description
GaSkia
GaSkia9mo ago
only form1.cs have u written in Program.cs?
ExileWeirdo
ExileWeirdo9mo 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
GaSkia9mo ago
ok where are these?
ExileWeirdo
ExileWeirdo9mo 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
GaSkia9mo 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
ExileWeirdo9mo ago
i should have
ExileWeirdo
ExileWeirdo9mo ago
here u get the designer too
GaSkia
GaSkia9mo ago
can u tell me the line number of this... I have to install the c# compiler... new pc
ExileWeirdo
ExileWeirdo9mo ago
No description
GaSkia
GaSkia9mo 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
ExileWeirdo9mo ago
didnt work last time cuz it said it didnt recognize svar in the namespace or smt
GaSkia
GaSkia9mo ago
try swapping and send the error
ExileWeirdo
ExileWeirdo9mo ago
No description
ExileWeirdo
ExileWeirdo9mo ago
the name 'svar' does not excist in the current context
GaSkia
GaSkia9mo ago
svar = lblSorteradData.Text
ExileWeirdo
ExileWeirdo9mo ago
thats just wrong tho cuz lblSorteradData.Text is the text in my results
GaSkia
GaSkia9mo ago
okok I see now i'll hop on windows give me two mnis
ExileWeirdo
ExileWeirdo9mo ago
sorry for troubling you
SinFluxx
SinFluxx9mo ago
Is validation true when you're clicking the sort button?
ExileWeirdo
ExileWeirdo9mo ago
where do i check that
SinFluxx
SinFluxx9mo ago
Well this is where you need to try debugging/setting breakpoints
ExileWeirdo
ExileWeirdo9mo ago
yeah im new to c# dont know them
SinFluxx
SinFluxx9mo 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
ExileWeirdo9mo ago
wdym set lbl = svar
SinFluxx
SinFluxx9mo 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
ExileWeirdo9mo 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
SinFluxx9mo ago
The else statement will execute, and then execution will return to the method that originally called it
ExileWeirdo
ExileWeirdo9mo ago
o what should i put to make it end just return;? or should i do a true or false statement?
SinFluxx
SinFluxx9mo ago
That will still then just return to the original method, you could change your else statement to svar = "Error! Fel data!";
GaSkia
GaSkia9mo ago
maybe I found the solution
ExileWeirdo
ExileWeirdo9mo ago
ooo ic what u mean sin
GaSkia
GaSkia9mo ago
go here
No description
GaSkia
GaSkia9mo ago
on the form click on the btn
ExileWeirdo
ExileWeirdo9mo ago
ye
GaSkia
GaSkia9mo ago
f4
ExileWeirdo
ExileWeirdo9mo ago
ye properties
GaSkia
GaSkia9mo ago
click the thunder btn
ExileWeirdo
ExileWeirdo9mo ago
ye actions
GaSkia
GaSkia9mo ago
and look for click and send pic
ExileWeirdo
ExileWeirdo9mo ago
wha this entire thing is already a click function
ExileWeirdo
ExileWeirdo9mo ago
No description
ExileWeirdo
ExileWeirdo9mo ago
btnSortera_Click
GaSkia
GaSkia9mo ago
ok send me a screen of properties-> envents
ExileWeirdo
ExileWeirdo9mo ago
dw
GaSkia
GaSkia9mo ago
u said nothing happen when u click so no error neither
ExileWeirdo
ExileWeirdo9mo ago
were getting somewhere
ExileWeirdo
ExileWeirdo9mo ago
No description
ExileWeirdo
ExileWeirdo9mo 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
ExileWeirdo9mo ago
No description
ExileWeirdo
ExileWeirdo9mo ago
No description
ExileWeirdo
ExileWeirdo9mo ago
this is the else if validation isnt true
GaSkia
GaSkia9mo ago
I've lost that conv on reset
ExileWeirdo
ExileWeirdo9mo ago
so validation isnt becoming true
SinFluxx
SinFluxx9mo ago
I think the problem is you're not calling ValidationTal() so validation never gets set
ExileWeirdo
ExileWeirdo9mo ago
im so kekw
GaSkia
GaSkia9mo ago
got no reference
No description
ExileWeirdo
ExileWeirdo9mo ago
i can confirm it is working. i feel like such an idiot haha forgeting to call the function
GaSkia
GaSkia9mo ago
things that happen
ExileWeirdo
ExileWeirdo9mo ago
time to error search my answer functions not coming out like i wanted them to
SinFluxx
SinFluxx9mo 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
GaSkia9mo ago
u at uni or highschool?
ExileWeirdo
ExileWeirdo9mo ago
swedish gymnasium 16 years old. i go to class with 17 year olds tho 1 year younger
GaSkia
GaSkia9mo ago
got it
ExileWeirdo
ExileWeirdo9mo 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
GaSkia9mo ago
u know javascript?
ExileWeirdo
ExileWeirdo9mo ago
im a big game fanatic too so 😄 ye javacsript and c# are very similiar
GaSkia
GaSkia9mo ago
yeah
ExileWeirdo
ExileWeirdo9mo ago
No description
ExileWeirdo
ExileWeirdo9mo ago
ah yes nice sorting weirdo
ExileWeirdo
ExileWeirdo9mo ago
No description
ExileWeirdo
ExileWeirdo9mo ago
ah yes nice sorting weirdo
Accord
Accord9mo 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.