Ver Mensaje Individual
  #5 (permalink)  
Antiguo 20/03/2011, 09:01
v1Tu
 
Fecha de Ingreso: agosto-2009
Mensajes: 5
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: Problema array

Estas son las variables

Dim x(0) As TextBox, i As Int16
Dim y(0) As TextBox, f As Int16
Dim subtotal, fondo As Double
Dim idpres As Integer
Dim p As Integer

Ahora el codigo de combobox y del boton calcular

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
For Me.i = 0 To ComboBox1.SelectedItem - 1
ReDim Preserve x(i)
x(i) = New TextBox
x(i).Name = "txtPres" & i
x(i).Text = x(i).Name
x(i).MaxLength = 25
x(i).Width = 150
If i <> 0 Then
x(i).Top = x(i - 1).Top + x(i).Height + 3
End If
Panel1.Controls.Add(x(i))
Next
For Me.f = 0 To ComboBox1.SelectedItem - 1
ReDim Preserve y(f)
y(f) = New TextBox
y(f).Name = "txtPresNum" & f
'y(f).Text = y(f).Name
y(f).TextAlign = HorizontalAlignment.Right
y(f).Width = 69
If f <> 0 Then
y(f).Top = y(f - 1).Top + y(f).Height + 3
End If
Panel2.Controls.Add(y(f))
Next
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
subtotal = 0
For Me.i = 0 To UBound(y)
subtotal = subtotal + Val(y(i).Text)
Next
TextBox7.Text = subtotal
fondo = subtotal * (10 / 100)
TextBox8.Text = fondo
TextBox16.Text = subtotal + fondo
For Me.i = 0 To UBound(y)
MsgBox(Val(y(i).Text))
Next
End Sub

Hay esta todo, si supongo que sea una tonteria pero no se el que puede ser y he estado probando muchas cosas y nada..

uso visual studio 2008