azrael211 Posted July 6, 2006 Posted July 6, 2006 I am currently writing a program for a ame I play, it works out the profit I will make from manufacturing stuff. The blueprint requires 1 or more components to build and item and my program wrks out the profitability of the item based on the amount produced and sell prices etc. Each component line has component name, unit/batch, cost/unit, units/30days I then perform some maths which takes the unit/batch * unit/cost = units/30days I can create 4 new text boxes under the original ones and give then names and perform the maths etc but I am wondering how I manage these once I get up to say 20 rows, I assume a control array which is now and event handler i beleive. I have read about event handlers which seems fine for one textbox but how do i address many textboxes when i dont know their names to control them? Thank you in advance for any help. Quote
Gill Bates Posted July 6, 2006 Posted July 6, 2006 Take a look at how the designer sets up the event handler for other controls. You need to do the same thing, except in an array. Quote
techmanbd Posted July 6, 2006 Posted July 6, 2006 Here is how I do it, The first code is where I set up a textbox array and calls for a handle. The second cose is a sub for the handle With txtFreqs(intL) .Size = New Size(56, 25) .Location = New Point(intTFX, intY) .Enabled = False .MaxLength = 6 .Name = "txtFreq" & intL.ToString AddHandler txtFreqs(intL).KeyPress, AddressOf HandlesTextBox End With This handle is so someone can only write numbers and use the backspace Private Sub HandlesTextBox(ByVal sender As Object, ByVal e As KeyPressEventArgs) If Not Char.IsNumber(e.KeyChar) And Not Asc(e.KeyChar) = 8 Then e.Handled = True End If End Sub Hope this helps and steers you in the right direction for what you are looking for Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
azrael211 Posted July 7, 2006 Author Posted July 7, 2006 Thank you for the help much appreciated. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.