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