Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...