C
C#12mo ago
Drei

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