Hello All,

I am a little new to .NET Developing, and have learned a great deal recently, but I'm stuck with something. I come from an ASP Background, so please excuse my ignorance ;-p

I'm trying to subtract 2 variables, but they don't seem to 'see' one another.

I can write the values in the page, subtracting one from another, but in the CODE BEHIND, I'm having some trouble. Mostly because I might not have a firm understanding of Private / Public / Shared Class - Declarations

I have 3 Variable Declared, so let me explain.

Public something1 As Integer = 0
Public something2 As Integer = 0
Public something3 As Integer = something1 - something2

Private Sub 1()
Do Something
something1 = myResults2

End Sub

Private Sub 2()
Do Something
something2 = myResults2

End Sub

Something3 isn't working. It's not Subtracting the values, I get a 0.

I'm used to writing INLINE VBScript on ASP Pages, so it just works. What am I missing here?

Hello All,

I am a little new to .NET Developing, and have learned a great deal recently, but I'm stuck with something. I come from an ASP Background, so please excuse my ignorance ;-p

I'm trying to subtract 2 variables, but they don't seem to 'see' one another.

I can write the values in the page, subtracting one from another, but in the CODE BEHIND, I'm having some trouble. Mostly because I might not have a firm understanding of Private / Public / Shared Class - Declarations

I have 3 Variable Declared, so let me explain.

Public something1 As Integer = 0
Public something2 As Integer = 0
Public something3 As Integer = something1 - something2

Private Sub 1()
Do Something
something1 = myResults2

End Sub

Private Sub 2()
Do Something
something2 = myResults2

End Sub

Something3 isn't working. It's not Subtracting the values, I get a 0.

I'm used to writing INLINE VBScript on ASP Pages, so it just works. What am I missing here?

A note: What I am trying to get at here is, how do I preform the something3, once those values have been set, in the code behind, because I will need the something3 for Subs.

hi, actually you can use public and private before variables and methods and classes also. But the difference is, if you want to access freely from out side the class then use "public"., if you want to use with in the class and to provide some security to your variable or method use "private".

What is code behind in VB.net? i cont understand please tell me.

i understand your problem, the problem is while you are declaring the variables you are initializing with 0. then you are subtracting
something3 = 0 - 0
it gives 0 to you. it is your code problem. if you want more explanation then give your full code.

Public IDCBCount As Integer
Public IDCBSaved As Integer
Public IDCBLeft As Integer = IDCBCount - IDCBSaved

Private Sub SavedData()
IDCBCount =8 + 1
End Sub

Private Sub Settings()
IDCBSaved = 6 'some saved data from a database
End Sub

This is it, in a nutshell.

I think what is happening is, my Variables are returning to 0 once my Subroutines are finished, and the Variables are not holding the changes in memory.

Just my thoughts.

Solved.

I was preforming Sub Routines out of order on the Sub Page_Load

This question has already been answered. Start a new discussion instead.