0
Problem with switch
Problem with this code is that, whatever code I input it outputs whats under deafult: here is code https://code.sololearn.com/cen2tdmYYuQX/?ref=app
8 odpowiedzi
+ 1
Code is local and never set. It can't get anything from your GUI without you physically making some assignment to it such as retriving the text box contents. Line 24 looks like an attempt to retrive the text box that is backwards. Changing it to the following might be what is needed:
code = Edit1->Text;
+ 1
Other minor point, having all those ifs, why bother with the switch. It is extra code to execute as you have already done the equivalent with those ifs.
+ 1
John Wells Thanks, it works
0
code doesn't get initialized so it isn't likely to match any if statements so br stays uninitialized. I can't address fmx or the undefined variables likely from there as they don't exist in my environment. However, maybe line 24 is backwards.
0
John Wells br I used because switch command needed integer values for it. and fmx is what program creates by itself so I don't do anything with it. I'm using RAD Studio XE8 if complier might be the problem (but 80% its not)
0
Yes, but that doesn't change the fact code is defined, but never given a value. I'm not sure where the value is expected to come from, but it hasn't.
0
John Wells I don't know what are you trying to say, probablg because I'm still a newbie. After user inputs the code and press the button, application will open an website inside it. But the problem is somewhere in switch part I guess
0
John Wells did it to set br since switch needed integer. But I know I can solve the issue with using ifs but wanted to improve switch skills