Results 1 to 2 of 2

Thread: getting the declared variable from inside [Resolved]

Threaded View

  1. #1

    Thread Starter
    Lively Member ayan's Avatar
    Join Date
    Jan 2004
    Posts
    112

    getting the declared variable from inside [Resolved]

    halu,

    i don't if the subject fits my needs here. i don't know what to put on the subject. hehehe... this is my problem...
    VB Code:
    1. Public Sub Add()
    2.         If TabPage1.Focus Then
    3.             Dim i As Integer
    4.             For i = 0 To Panel1.Controls.Count - 1
    5.                 If TypeOf Panel1.Controls(i) Is TextBox Then
    6.                     Dim t As TextBox = Panel1.Controls(i)
    7.                 ElseIf TypeOf Panel1.Controls(i) Is ComboBox Then
    8.                     Dim t As ComboBox = Panel1.Controls(i)
    9.                 End If
    10.                 'getting t here
    11.             Next
    12.         End If
    13.     End Sub
    is it possible? if it is how? just asking cause my code here goes like this...
    VB Code:
    1. Public Sub Add()
    2.         If TabPage1.Focus Then
    3.             Dim i As Integer
    4.             For i = 0 To Panel1.Controls.Count - 1
    5.                 If TypeOf Panel1.Controls(i) Is TextBox Then
    6.                     Dim t As TextBox = Panel1.Controls(i)
    7.                     'some conditions of t.text=string.empty
    8.                     'do something
    9.                 ElseIf TypeOf Panel1.Controls(i) Is ComboBox Then
    10.                     Dim t As ComboBox = Panel1.Controls(i)
    11.                     'some conditions of t.text=string.empty
    12.                     'do something
    13.                 End If
    14.             Next
    15.         End If
    16.     End Sub
    it's kinda redundant on having some conditions of control.text=string.empty and doing something there. the same function is done...

    this kinda sort for beginners... hehehe... any help is greatly appreciated. i'm a newbie though but a wanna be...

    or...... any ideas more elegant than mine...
    Last edited by ayan; Feb 3rd, 2004 at 04:35 AM.

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