Results 1 to 2 of 2

Thread: VB6 code translation...

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    VB6 code translation...

    Hello, In VB6 I had a collection of textboxes which I could iterate through with For Each....

    Control names were txtFactor .....and indexed like this..

    txtFactor(0)
    txtFactor(1)
    txtFactor(2)
    etc....

    In VB6:

    Dim txtTemp as textbox

    For Each txtTemp In txtFactor
    txtTemp.Enabled = False
    Next txtTemp

    which basically does this......in VB.NET after renaming the controls.

    txtFactor0.Enabled = False
    txtFactor1.Enabled = False
    txtFactor1.Enabled = False
    txtFactor2.Enabled = False
    txtFactor3.Enabled = False
    txtFactor4.Enabled = False
    txtFactor5.Enabled = False

    What VB.NET equivalent can I use?

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830
    Handled it like this.......

    Private Sub DisableNumericUpDown(ByVal ctrlParent As Control)
    Dim ctrl As Control
    For Each ctrl In ctrlParent.Controls
    If TypeOf ctrl Is NumericUpDown Then
    ctrl.Enabled = False
    End If
    ' If the control has children,
    ' recursively call this function
    If ctrl.HasChildren Then
    ctrl.Enabled = False
    End If
    Next
    End Sub



    This called it like this.....

    Dim nupTemp As System.Windows.Forms.NumericUpDown

    DisableNumericUpDown(nupTemp)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width