Bueno tengo un problema con unos codigos en visual basic .net, asi q pido ayuda nuevamente a los expertos, el codigo no sta mal, simplemente fijense la imagen y enteran mejor cual es el problema, este codigo es sobre un cajero automatico la cosa es q pues se hace tres retiros como se muestra en la imagen y pues abjo de ellos me sale ''total retiros=3'', hasta ahi va bien, luego se hace otros 4 retiros mas y me sale esto ''total retiros=7'' osea deberia salirme 4 pero me sale 7, parece q esta sumando el total de todoss los retiros hechos y pues yo no deseo eso, a ver si me ayudan y fijense la imagen para q se puedan guiar por favor, es una tarea...
Public Class Form1
Private Sub btnretirar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnretirar.Click
Dim x, y, c, b, d, m, h, g As Integer
Dim a As String
Static z, k As Integer
d = InputBox("Ingrese tope maximo", "ATENCION")
Me.txtlimite.Text = d
Me.lista1.Items.Add("Bloque 1" & "=" & d)
Do
a = InputBox("Ingrese un nombre", "Atencion")
k = k + 1
g = g + 1
m = m + 1
Do
b = InputBox("Ingrese una cantidad", "Atencion")
If b > Val(txtlimite.Text) Then
MsgBox("Cantidad no admitida", MsgBoxStyle.Critical)
'b = 0
Me.txtcant.Text = b
End If
Loop While b > Val(txtlimite.Text)
Me.txtcant.Text = b
x = x + b
If x < Val(txtlimite.Text) Then
h = x
Me.txtsuma.Text = h
End If
While x > Val(txtlimite.Text)
MsgBox("Cantidad no admitida", MsgBoxStyle.Critical)
x = x - b
b = InputBox("Ingrese una cantidad", "Atencion")
x = x + b
Me.txtsuma.Text = Val(x)
End While
Me.lista1.Items.Add(a & " " & b)
If x = Val(txtlimite.Text) Then
If MsgBox("Desea continuar", 4, "Atencion") = 7 Then
Me.lista1.Items.Add("")
Me.lista1.Items.Add("Total retiros=" & m)
Me.lista1.Items.Add("")
z = z + 1
y = y + x
Me.lista1.Items.Add("Se realizo" & z & " " & "bloques de retiro de dinero de " & y & " " & "con un total de " & " " & k & " " & "clientes")
Me.lista1.Items.Add("")
'y = y + x
Me.lista1.Items.Add("Suma de bloques:" & y)
Exit Sub
Else
Me.lista1.Items.Add("Total retiros=" & m)
y = y + x
x = 0
c = InputBox("Ingrese un nuevo tope", "Atencion")
Me.txtlimite.Text = c
Me.lista1.Items.Add("")
z = z + 1
Me.lista1.Items.Add("Bloque" & z + 1 & "=" & c)
Me.lista1.Items.Add(" ")
End If
End If
Loop
End Sub
End Class
[img=http://img386.imageshack.us/img386/2956/visualnn7.th.png]
Public Class Form1
Private Sub btnretirar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnretirar.Click
Dim x, y, c, b, d, m, h, g As Integer
Dim a As String
Static z, k As Integer
d = InputBox("Ingrese tope maximo", "ATENCION")
Me.txtlimite.Text = d
Me.lista1.Items.Add("Bloque 1" & "=" & d)
Do
a = InputBox("Ingrese un nombre", "Atencion")
k = k + 1
g = g + 1
m = m + 1
Do
b = InputBox("Ingrese una cantidad", "Atencion")
If b > Val(txtlimite.Text) Then
MsgBox("Cantidad no admitida", MsgBoxStyle.Critical)
'b = 0
Me.txtcant.Text = b
End If
Loop While b > Val(txtlimite.Text)
Me.txtcant.Text = b
x = x + b
If x < Val(txtlimite.Text) Then
h = x
Me.txtsuma.Text = h
End If
While x > Val(txtlimite.Text)
MsgBox("Cantidad no admitida", MsgBoxStyle.Critical)
x = x - b
b = InputBox("Ingrese una cantidad", "Atencion")
x = x + b
Me.txtsuma.Text = Val(x)
End While
Me.lista1.Items.Add(a & " " & b)
If x = Val(txtlimite.Text) Then
If MsgBox("Desea continuar", 4, "Atencion") = 7 Then
Me.lista1.Items.Add("")
Me.lista1.Items.Add("Total retiros=" & m)
Me.lista1.Items.Add("")
z = z + 1
y = y + x
Me.lista1.Items.Add("Se realizo" & z & " " & "bloques de retiro de dinero de " & y & " " & "con un total de " & " " & k & " " & "clientes")
Me.lista1.Items.Add("")
'y = y + x
Me.lista1.Items.Add("Suma de bloques:" & y)
Exit Sub
Else
Me.lista1.Items.Add("Total retiros=" & m)
y = y + x
x = 0
c = InputBox("Ingrese un nuevo tope", "Atencion")
Me.txtlimite.Text = c
Me.lista1.Items.Add("")
z = z + 1
Me.lista1.Items.Add("Bloque" & z + 1 & "=" & c)
Me.lista1.Items.Add(" ")
End If
End If
Loop
End Sub
End Class
[img=http://img386.imageshack.us/img386/2956/visualnn7.th.png]
