Public Class Form3
'Public txtIN As TextBox
Dim lbl As Label
Dim arrival As TextBox()
Dim inp As Integer
Dim y As Integer
Dim x As Integer
Dim a, b As Integer
Public arrival_time(9) As Integer
Public burst_time(9) As Integer
Public AT() As Integer
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
inp = Val(Form1.txtINPUT.Text)
b = 50
For ctr As Integer = 0 To inp - 1
Dim lbl As New Label
lbl.SetBounds(30, b, 30, 25)
lbl.Text = "P" + Str(ctr + 1)
Me.Controls.Add(lbl)
Dim arrival(inp) As TextBox
arrival(ctr) = New TextBox
arrival(ctr).SetBounds(109, b, 50, 25)
arrival_time(ctr) = Val(arrival(ctr).Text)
Controls.Add(arrival(ctr))
Dim burst As TextBox
burst = New TextBox
burst.SetBounds(217, b, 50, 25)
Controls.Add(burst)
burst_time(ctr) = Val(burst.Text)
Dim c As New Label
c.SetBounds(30, b, 30, 25)
c.Text = "time: " + Str(arrival_time(ctr))
Me.Controls.Add(c)
b = b + 30
Next ctr
End Sub
Private Sub btnGET_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGET.Click
Label4.Text = Str(arrival_time(0))
Label5.Text = Str(arrival_time(1))
Label6.Text = Str(arrival_time(2))
End Sub
End Class
put the values of textbox into an array
Page 1 of 14 Replies - 2078 Views - Last Post: 17 February 2011 - 11:02 AM
#1
put the values of textbox into an array
Posted 17 February 2011 - 10:33 AM
need help guys, I'm working on my code about cpu scheduling and I encountered a problem in putting the values inputted of the user from the textbox to an array, when I try to retrieve the value from the array I always get '0' and I don't know where did I get that 0. here's my code hope you could help me >___<
Replies To: put the values of textbox into an array
#2
Re: put the values of textbox into an array
Posted 17 February 2011 - 10:37 AM
Is there a reason why you are doing line 29?
Dim arrival(inp) As TextBox
#3
Re: put the values of textbox into an array
Posted 17 February 2011 - 10:41 AM
#4
Re: put the values of textbox into an array
Posted 17 February 2011 - 10:50 AM
That's what I figured.
Okay, for loops... they loop, right? Repeat instructions. If you declare an object inside of a for loop each time that loop comes back around again that object is re-declared.
In this case you are perpetually declaring an array of size "inp", and then going to a specific element (of this empty array) to add something create a new textbox.
That doesn't make much sense, right?
Okay, for loops... they loop, right? Repeat instructions. If you declare an object inside of a for loop each time that loop comes back around again that object is re-declared.
In this case you are perpetually declaring an array of size "inp", and then going to a specific element (of this empty array) to add something create a new textbox.
That doesn't make much sense, right?
#5
Re: put the values of textbox into an array
Posted 17 February 2011 - 11:02 AM
OHHHHH!! I see sir!! thanks for pointing that matter! I'll work on my code again xD thanks Sir!
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote








|