C
C#7mo ago
Dan

✅ no results?

hi can someone help me with my code? it launches and works but i dont think its doing what its suppose to do which is the adding and dividing it just results to 0. is it working?? (this VB)
No description
133 Replies
Dan
Dan7mo ago
Already got all the codes labeled idk whats missing Dim _GQ As Double Dim _GT As Double Dim _GO As Double Dim _SM As Double Dim _AE As Double Dim _SU As Double Dim _AV As Double _GQ = Val(TextBox1.Text) _GT = Val(TextBox6.Text) _GO = Val(TextBox7.Text) _SM = Val(TextBox2.Text) _AE = Val(TextBox3.Text) _SM = _GQ + _GT + _GO + _SM TextBox4.Text = _SU _AE = _GQ + _GT + _GO / 3 TextBox5.Text = _AV
Buddy
Buddy7mo ago
use the debugger $debug
MODiX
MODiX7mo ago
Tutorial: Debug C# code - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
Buddy
Buddy7mo ago
This server is generally for C# though. But exceptions can be made from time to time, as well in #other-langs $vb
Dan
Dan7mo ago
alr but little help though on this pls how does that work
Buddy
Buddy7mo ago
Press F9 on whatever line you want to break at it will mark that line, so whenever the execution hits that point it will break and it will allow you to view all values and interact with them. Note that you must start your program in debug (F5) You are aware that _SM is not being used, right?
Dan
Dan7mo ago
o where did i miss
Buddy
Buddy7mo ago
A faded color means it's not being used anywhere
No description
Dan
Dan7mo ago
is that why its 0??
Buddy
Buddy7mo ago
Try 😄
Dan
Dan7mo ago
ill break that? idk how the break doesd
Buddy
Buddy7mo ago
No description
Buddy
Buddy7mo ago
Check line 16 and 17
Dan
Dan7mo ago
ill break em?
Buddy
Buddy7mo ago
Set a breakpoint at line 16 by pressing F9. Then start your program by pressing F5
Dan
Dan7mo ago
so 16 and 17?
Buddy
Buddy7mo ago
If you want to set a breakpoint at line 17 too, sure.
Dan
Dan7mo ago
alr then ill start do i just try to compute now or still 0 though
Buddy
Buddy7mo ago
Yes Does it ever hit that point?
Dan
Dan7mo ago
honestly idk how will i know
Buddy
Buddy7mo ago
The program should freeze and Visual Studio is going to pop up
Dan
Dan7mo ago
well it just did open the form
Buddy
Buddy7mo ago
Do the calculation
Dan
Dan7mo ago
No description
Buddy
Buddy7mo ago
Try setting the value at line 17 to _SM
Dan
Dan7mo ago
ill move it to 17?
Buddy
Buddy7mo ago
_SM = _GQ + _GT + _GO + _SM
TextBox4.Text = _SU
_SM = _GQ + _GT + _GO + _SM
TextBox4.Text = _SU
You are not using the _SM variable If that is what you want to achieve that is But I would recommend to learn how to debug your program, it is basically the #1 tool for developers
Dan
Dan7mo ago
it finds and fixes the errors? also whats the point of _SM that the Sum result though how is it not used
Buddy
Buddy7mo ago
It doesn't fix the errors, it isn't an AI or anything. It just shows you the values at runtime
Dan
Dan7mo ago
mm ok but when i run debug F5, is there like a log or smth to show that
Buddy
Buddy7mo ago
When you press F9 on a line, do you see anything in your editor? Such as a red dot next to the line number (left side)
Dan
Dan7mo ago
white big dot i see
Dan
Dan7mo ago
No description
Buddy
Buddy7mo ago
Do me a favor, set a breakpoint at line 17. and try again
Dan
Dan7mo ago
am i right?
No description
Buddy
Buddy7mo ago
Oh you have errors that is why
Dan
Dan7mo ago
yea
Buddy
Buddy7mo ago
It is running an old build
Dan
Dan7mo ago
idk should i show u the error ey wym
Buddy
Buddy7mo ago
You cannot compile an app if it has syntax error and visual studio runs an old build if it fails to compile
Dan
Dan7mo ago
ur saying my visual studio is outdated
Buddy
Buddy7mo ago
No
Dan
Dan7mo ago
whats the old build
Buddy
Buddy7mo ago
Please go into Options in Visual Studio, navigate to Project And Solutions, then navigate to Build and Run. And then set these options to whatever is mentioned in the screenshot
No description
Buddy
Buddy7mo ago
old build meaning an old version of your program (the sum and average program)
Dan
Dan7mo ago
ah alr hol on i forgor where options is tools wirght right alr done then i launch my form?
Buddy
Buddy7mo ago
Correct It should give you errors and refuse to start your program if you get errors Do not ignore errors, you must fix them to be able to build (compile) your program.
Dan
Dan7mo ago
still getting the 3 errors
Buddy
Buddy7mo ago
Yes, you must fix them
Dan
Dan7mo ago
No description
Dan
Dan7mo ago
what does the errors mean??
Buddy
Buddy7mo ago
You have multiple methods of the same name
Dan
Dan7mo ago
which methods
Buddy
Buddy7mo ago
Button1_Click
TextBox1_TextChanged
Form1_Load
Button1_Click
TextBox1_TextChanged
Form1_Load
Given your screenshot, I can already seen two that you don't need.
Dan
Dan7mo ago
_SM?
Buddy
Buddy7mo ago
No description
Buddy
Buddy7mo ago
These two
Dan
Dan7mo ago
should i delete em o r those the errors
Buddy
Buddy7mo ago
To fix two of your errors, yeah
Dan
Dan7mo ago
oh alr idk i just randomly click some Elements in the form n it leads me to the vb i thought those dont matter error wants the end sub to be end class
Buddy
Buddy7mo ago
They do matter and give you errors if you have multiple methods of the same name and same parameter types (same signature)
Dan
Dan7mo ago
ic priv button 1 says it got multiple definitions what else is wrong
Buddy
Buddy7mo ago
Read the error and try to understand based on what I previously wrote
Dan
Dan7mo ago
still kinda lost fixing the error requires to change the procedure name it said in micro
Buddy
Buddy7mo ago
Look up where I mentioned signature here
No description
Buddy
Buddy7mo ago
And how did you solve your previous two errors? As they all three are of the same error type
Dan
Dan7mo ago
deleting em
Buddy
Buddy7mo ago
So how do you solve this error if the previous two errors were of the same type?
Dan
Dan7mo ago
changing the name?
Buddy
Buddy7mo ago
🙂
Dan
Dan7mo ago
oh silly me which though
Buddy
Buddy7mo ago
Mind pasting the entire code? $paste
MODiX
MODiX7mo ago
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
Dan
Dan7mo ago
idk what to delete exact Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim _GQ As Double Dim _GT As Double Dim _GO As Double Dim _SM As Double Dim _AE As Double Dim _SU As Double Dim _AV As Double _GQ = Val(TextBox1.Text) _GT = Val(TextBox6.Text) _GO = Val(TextBox7.Text) _SM = Val(TextBox2.Text) _AE = Val(TextBox3.Text) _SM = _GQ + _GT + _GO + _SM TextBox4.Text = _SU _AE = _GQ + _GT + _GO / 3 TextBox5.Text = _AV End Sub
Buddy
Buddy7mo ago
Scroll up to the red dot
No description
Buddy
Buddy7mo ago
Red dot under the scrollbar indicates where an error is (right side)
Dan
Dan7mo ago
its smh pointing to Public Class forml should i delete it it also does want Class for End sub which cant be
Buddy
Buddy7mo ago
No - Don't delete it
Dan
Dan7mo ago
alr
Buddy
Buddy7mo ago
Please show the project explorer (From Visual Studio)
Dan
Dan7mo ago
No description
Dan
Dan7mo ago
i forgot to remove form 2
Buddy
Buddy7mo ago
Then remove it and try to compile your app again
Dan
Dan7mo ago
still down the 2 errors still continues. is there a thing interupting the code in my explorer?? looks like nothing is though
Buddy
Buddy7mo ago
Press CTRL + Shift + F, type Button1_Click and search for it That will find all occurances, please screenshot the result
Dan
Dan7mo ago
No description
Dan
Dan7mo ago
still from the same line
Buddy
Buddy7mo ago
You seem to have two occurances though
Buddy
Buddy7mo ago
double-click the first occurance (on the code part)
No description
Dan
Dan7mo ago
leads to the text dosent really do anything
Buddy
Buddy7mo ago
Is it the same text? As in exactly the same
Dan
Dan7mo ago
yea cuh the text from the private sub same
Buddy
Buddy7mo ago
But everything else are the methods you removed earlier still there?
Dan
Dan7mo ago
its already deleted no
Buddy
Buddy7mo ago
right-click your project in solution explorer and find 'edit project file'
No description
Buddy
Buddy7mo ago
paste the contents of the file opened here
Dan
Dan7mo ago
where can i do that explorer?
Buddy
Buddy7mo ago
This
No description
Dan
Dan7mo ago
im in
Dan
Dan7mo ago
No description
Buddy
Buddy7mo ago
Delete these lines
Buddy
Buddy7mo ago
No description
Dan
Dan7mo ago
alr
Dan
Dan7mo ago
clear?
No description
Buddy
Buddy7mo ago
Correct Save and try to build again
Dan
Dan7mo ago
start?
Buddy
Buddy7mo ago
Yes
Dan
Dan7mo ago
ok, this one is just left
No description
Dan
Dan7mo ago
but its sub, idk how to get this out
Buddy
Buddy7mo ago
Please paste the code
Dan
Dan7mo ago
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim _GQ As Double Dim _GT As Double Dim _GO As Double Dim _SM As Double Dim _AE As Double Dim _SU As Double Dim _AV As Double _GQ = Val(TextBox1.Text) _GT = Val(TextBox6.Text) _GO = Val(TextBox7.Text) _SM = Val(TextBox2.Text) _AE = Val(TextBox3.Text) _SM = _GQ + _GT + _GO + _SM TextBox4.Text = _SU _AE = _GQ + _GT + _GO / 3 TextBox5.Text = _AV End Sub
Buddy
Buddy7mo ago
Insert an End Class at the end of the code
Dan
Dan7mo ago
but not the end sub?
Buddy
Buddy7mo ago
Like this
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim _GQ As Double
Dim _GT As Double
Dim _GO As Double
Dim _SM As Double
Dim _AE As Double
Dim _SU As Double
Dim _AV As Double
_GQ = Val(TextBox1.Text)
_GT = Val(TextBox6.Text)
_GO = Val(TextBox7.Text)
_SM = Val(TextBox2.Text)
_AE = Val(TextBox3.Text)

_SM = _GQ + _GT + _GO + _SM
TextBox4.Text = _SU

_AE = _GQ + _GT + _GO / 3
TextBox5.Text = _AV
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim _GQ As Double
Dim _GT As Double
Dim _GO As Double
Dim _SM As Double
Dim _AE As Double
Dim _SU As Double
Dim _AV As Double
_GQ = Val(TextBox1.Text)
_GT = Val(TextBox6.Text)
_GO = Val(TextBox7.Text)
_SM = Val(TextBox2.Text)
_AE = Val(TextBox3.Text)

_SM = _GQ + _GT + _GO + _SM
TextBox4.Text = _SU

_AE = _GQ + _GT + _GO / 3
TextBox5.Text = _AV
End Sub
End Class
Dan
Dan7mo ago
o moment of truth mm odd is it in debug
Dan
Dan7mo ago
No description
Buddy
Buddy7mo ago
That is the breakpoint hitting
Dan
Dan7mo ago
alr looks like its 0 still the results dosent remove when i press F9 again
Buddy
Buddy7mo ago
It does
Dan
Dan7mo ago
how
Buddy
Buddy7mo ago
Press this button if you want to continue execution
No description
Buddy
Buddy7mo ago
But remember what I mentioned before?
Dan
Dan7mo ago
No description
Buddy
Buddy7mo ago
This
Dan
Dan7mo ago
i do know that but
Buddy
Buddy7mo ago
What is TextBox2?
Dan
Dan7mo ago
what will i use for reference the name of the texbox its 2
Buddy
Buddy7mo ago
Oh, actually you are never setting _SU that is why it is 0
Dim _GQ As Double
Dim _GT As Double
Dim _GO As Double
Dim _SM As Double
Dim _AE As Double
Dim _SU As Double
Dim _AV As Double
_GQ = Val(TextBox1.Text)
_GT = Val(TextBox6.Text)
_GO = Val(TextBox7.Text)
_SM = Val(TextBox2.Text)
_AE = Val(TextBox3.Text)
Dim _GQ As Double
Dim _GT As Double
Dim _GO As Double
Dim _SM As Double
Dim _AE As Double
Dim _SU As Double
Dim _AV As Double
_GQ = Val(TextBox1.Text)
_GT = Val(TextBox6.Text)
_GO = Val(TextBox7.Text)
_SM = Val(TextBox2.Text)
_AE = Val(TextBox3.Text)
You never set the value of _SU
Dan
Dan7mo ago
so i have to add or replace SM to SU?
Buddy
Buddy7mo ago
just replace
TextBox4.Text = _SU
TextBox4.Text = _SU
with
TextBox4.Text = _SM
TextBox4.Text = _SM
if that is what you want to do
Dan
Dan7mo ago
ok its all working now thanks for the big help thanks for having patience or smth bro im still new to this honestly 🤔
Buddy
Buddy7mo ago
No problem! Good luck.