increment

dezreena

Member
Joined
Mar 29, 2007
Messages
20
Programming Experience
Beginner
hello guys, im using VB.NET.
i have 2 value(x,s) to increase simultaneously.is it possible?because i try to debugg it , but the output said im only calculating the value.how can i increase the 2 value simultanously?

a buch of thanks!!
VB.NET:
Public Class Form1
 
Dim i, k, Anzahl As Integer
Dim vIndex As Integer
Dim x As Integer
Dim s As Integer
 
 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Anzahl = Val(TextBox1.Text)
 
berechnen()
initialisieren()
 
Incr(s, x)
 
 
End Sub
 
Function Incr(ByVal x As Integer, ByVal s As Integer, Optional ByVal nStep As Long = 1) As Long
 
 
For i = 1 To Anzahl
vIndex = vIndex + nStep
k = vIndex
k = MessageBox.Show((k), i)
 
Next
End Function
 
 
 
Sub initialisieren()
 
x = 20
vIndex = x
 
End Sub
 
 
Sub berechnen()
 
s = 100
vIndex = s
 
End Sub
End Class
output= 21,22,23= x value
 
Last edited by a moderator:
what are you expecting this code to do?

You name x and s at the top (class-wide variables)
You again use x and s to refer to local variables within Incr() (very bad idea)
You do nothing with either x or either s in Incr()

To answer your question, it is only possible to increment 2 variables simultaneously if you have 2 CPUs. One CPU cannot increment 2 separate variables simultaneously in the same way that you cannot drive 2 cars simultaneously (one to berlin, one to munich)
 
Back
Top