By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,512 Members | 3,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,512 IT Pros & Developers. It's quick & easy.

I am able write a code in vb but not able to implement a similar in vb.net

seshu
100+
P: 156
hi every body
This is seshu, here iam able write a code in vb6 on controle arrays ofcourse while designing it self i made my controls as arrays but here in .net i dint find that option see the code in vb6 is like this

Expand|Select|Wrap|Line Numbers
  1. Dim cont
  2. For Each cont In form
  3.     If TypeName(cont) = "TextBox" Then cont.Text = ""
  4. Next
and the code in vb.net is like this

Expand|Select|Wrap|Line Numbers
  1.  Dim cont As Form1.Controls
  2.         For each cont in me.controls
  3.             If TypeName(cont(i)) = "TextBox" Then
  4.                 If cont.text = " " Then
  5.                     MsgBox("Please fill all the details")
  6.                 End If
  7.             End If
  8.         Next
please show me the mistake or write code and what i want here is on a button click it should check where all the textboxs are filled or not
thanking you
regards
seshu
Jan 10 '07 #1
Share this Question
Share on Google+
8 Replies


hariharanmca
100+
P: 1,977
hi every body
This is seshu, here iam able write a code in vb6 on controle arrays ofcourse while designing it self i made my controls as arrays but here in .net i dint find that option see the code in vb6 is like this

Expand|Select|Wrap|Line Numbers
  1. Dim cont
  2. For Each cont In form
  3.     If TypeName(cont) = "TextBox" Then cont.Text = ""
  4. Next
and the code in vb.net is like this

Expand|Select|Wrap|Line Numbers
  1.  Dim cont As Form1.Controls
  2.         For each cont in me.controls
  3.             If TypeName(cont(i)) = "TextBox" Then
  4.                 If cont.text = " " Then
  5.                     MsgBox("Please fill all the details")
  6.                 End If
  7.             End If
  8.         Next
please show me the mistake or write code and what i want here is on a button click it should check where all the textboxs are filled or not
thanking you
regards
seshu

You are not using i for any increment or decrement, then why you are using i

Just try this

Dim cont As controls
For each cont in me.controls
If TypeName(cont) = "TextBox" Then
If cont.text = " " Then MsgBox("Please fill all the details")
End If
Next
Jan 10 '07 #2

seshu
100+
P: 156
hi hari
this is seshu i tried that but still it is not showing the massage box if i click on the button with out fill the text in textboxes i think u understood my problem i hope u com back with some anser or good idea becos it urgent to me
Thanking you
regards
seshu
Jan 10 '07 #3

hariharanmca
100+
P: 1,977
hi hari
this is seshu i tried that but still it is not showing the massage box if i click on the button with out fill the text in textboxes i think u understood my problem i hope u com back with some anser or good idea becos it urgent to me
Thanking you
regards
seshu

Yes, I Got it it's not me.controls
its me only

Dim cont As controls
For each cont in me ‘me.controls
If TypeName(cont) = "TextBox" Then
If cont.text = " " Then MsgBox("Please fill all the details")
End If
Next

If you got answer reply
Jan 10 '07 #4

hariharanmca
100+
P: 1,977
Yes, I Got it it's not me.controls
its me only

Dim cont As controls
For each cont in me ‘me.controls
If TypeName(cont) = "TextBox" Then
If cont.text = " " Then MsgBox("Please fill all the details")
End If
Next

If you got answer reply

i got answer

you are giving space cont.text = " "
it should be like cont.text = ""


Dim cont As controls
For each cont in me.controls
If TypeName(cont) = "TextBox" Then
If cont.text = "" Then MsgBox("Please fill all the details")
End If
Next
Jan 10 '07 #5

seshu
100+
P: 156
thanks for your help this happens every time i dont have a habit of cheking small thing in hurry any how i think here after i will be even after them
any how thanks a lot
regards
seshu
Jan 10 '07 #6

hariharanmca
100+
P: 1,977
thanks for your help this happens every time i dont have a habit of cheking small thing in hurry any how i think here after i will be even after them
any how thanks a lot
regards
seshu

Its Ok elephant don’t know ants
Jan 10 '07 #7

seshu
100+
P: 156
hi struck in the same place again this time i have implemented the same code in another form with a panel containing three group boxes and each group box containg the text boxes and ithink the code should be same thats the reason i wrote the same above code but its not work can any one say the reson why
regards
seshu
Jan 11 '07 #8

seshu
100+
P: 156
iam really sorry i found the anser it should be groupbox1.controles insted of me.controles one more thing if there is any way to delete this whole query please do that sorry guys
regards
seshu
Jan 11 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.