✅ 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)
133 Replies
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
use the debugger
$debug
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.
This server is generally for C# though. But exceptions can be made from time to time, as well in #other-langs
$vb
alr
but little help though on this pls
how does that work
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?o where
did i miss
A faded color means it's not being used anywhere
is that why its 0??
Try 😄
ill break that?
idk how the break doesd
Check line 16 and 17
ill break em?
Set a breakpoint at line 16 by pressing F9. Then start your program by pressing F5
so 16 and 17?
If you want to set a breakpoint at line 17 too, sure.
alr then ill start
do i just try to compute now or
still 0 though
Yes
Does it ever hit that point?
honestly idk
how will i know
The program should freeze and Visual Studio is going to pop up
well it just did open the form
Do the calculation
Try setting the value at line 17 to
_SM
ill move it to 17?
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 developersit finds and fixes the errors?
also whats the point of _SM that the Sum result though how is it not used
It doesn't fix the errors, it isn't an AI or anything. It just shows you the values at runtime
mm ok
but when i run debug F5, is there like a log or smth to show that
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)
white big dot i see
Do me a favor, set a breakpoint at line 17.
and try again
am i right?
Oh you have errors
that is why
yea
It is running an old build
idk should i show u the error
ey wym
You cannot compile an app if it has syntax error
and visual studio runs an old build if it fails to compile
ur saying my visual studio is outdated
No
whats the old build
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
old build meaning an old version of your program (the sum and average program)
ah
alr hol on
i forgor where options is
tools wirght
right
alr done
then i launch my form?
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.
still getting the 3 errors
Yes, you must fix them
what does the errors mean??
You have multiple methods of the same name
which methods
Given your screenshot, I can already seen two that you don't need.
_SM?
These two
should i delete em
o r those the errors
To fix two of your errors, yeah
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
They do matter and give you errors if you have multiple methods of the same name and same parameter types (same signature)
ic
priv button 1 says it got multiple definitions
what else is wrong
Read the error and try to understand based on what I previously wrote
still kinda lost
fixing the error requires to change the procedure name it said in micro
Look up where I mentioned signature here
And how did you solve your previous two errors?
As they all three are of the same error type
deleting em
So how do you solve this error if the previous two errors were of the same type?
changing the name?
🙂
oh silly me which though
Mind pasting the entire code? $paste
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!
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
Scroll up to the red dot
Red dot under the scrollbar indicates where an error is (right side)
its smh pointing to Public Class forml
should i delete it
it also does want Class for End sub which cant be
No - Don't delete it
alr
Please show the project explorer (From Visual Studio)
i forgot to remove form 2
Then remove it and try to compile your app again
still down
the 2 errors still continues. is there a thing interupting the code in my explorer??
looks like nothing is though
Press CTRL + Shift + F, type
Button1_Click
and search for it
That will find all occurances, please screenshot the resultstill from the same line
You seem to have two occurances though
double-click the first occurance (on the code part)
leads to the text
dosent really do anything
Is it the same text?
As in exactly the same
yea cuh
the text from the private sub
same
But everything else
are the methods you removed earlier still there?
its already deleted no
right-click your project in solution explorer and find 'edit project file'
paste the contents of the file opened here
where can i do that
explorer?
This
im in
Delete these lines
alr
clear?
Correct
Save and try to build again
start?
Yes
ok, this one is just left
but its sub, idk how to get this out
Please paste the code
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
Insert an
End Class
at the end of the codebut not the end sub?
Like this
o
moment of truth
mm odd
is it in debug
That is the breakpoint hitting
alr looks like its 0 still the results
dosent remove when i press F9 again
It does
how
Press this button if you want to continue execution
But remember what I mentioned before?
This
i do know that
but
What is TextBox2?
what will i use for reference
the name of the texbox
its 2
Oh, actually
you are never setting _SU
that is why it is 0
You never set the value of
_SU
so i have to add or replace
SM to SU?
just replace
with
if that is what you want to do
ok
its all working now
thanks for the big help
thanks for having patience or smth bro im still new to this honestly 🤔
No problem!
Good luck.