More Visual Basic Answers
Question Library
Ask a question about Visual Basic
Volunteer
Experts of the Month
Expert Login
Awards
About Us
Tell friends
Link to Us
Disclaimer
|
| |
|
|
| |
| | | |
About Ravindra
Expertise visual basic application programming from design to access information, sql, engineering and commercial applications. access databases, excel.
Optional:
1)a large number of people want me to do work which takes some time and effort. Pl.note that i would like to be paid for such work.
2) if you want me to spend quality time and do special work, i expect to be paid a reasonable price for my time.
3) if you are pleased with my reply you could consider a donation of 1$.
4) you can visit my website http://ravindra.coolpage.biz (under constrn)
Experience
Past/Present clients project work for a Norway company, and a Canadian company completed. Freelance Project work and Teaching
teaching vb
| | |
| |
You are here: Experts > Computing/Technology > Basic > Visual Basic > How to pass an array of TextBoxes by parameter to a Sub
Expert: Ravindra
Date: 10/9/2008
Subject: How to pass an array of TextBoxes by parameter to a Sub
Question Hi Ravindra,
I am working with Visual Basic 6.0 and my level is intermediate.
I am working with forms containing many text boxes, and I had the idea of grouping them, in order to make easier the common tasks as validation and initialization.
I have a form with 3 text-boxes as an array of controls (Text1), and a button (Command1) that has to erase the contents of the text boxes.
What I want to do is the following: in the OnClick of the button, call a Sub (Sub Delete) and pass the array of text boxes as a parameter to the Sub
This is my actual code:
Private Sub Command1_Click()
Call delete(Text1())
End Sub
Sub delete(ByRef textbox() As Control)
Dim i As Integer
For i = 1 To 3
textbox(i).Text = ""
Next
End Sub
The problem I have is that when I press the button, the following error is displayed, in the line of the Call delete:
Compilation Error: Type mismatch: A matrix or a user defined type was expected.
PD: If you don't understand something because of my level of English, please let me know and I will try to explain it better.
Thanks!
Answer have all the textboxs in one array and use this code to empty them
Option Explicit
Private Sub Command_click()
blanker (0)
'or blanker(3) etc
End Sub
Private Sub blanker(olage As Integer)
On Error Resume Next
For olage = olage To olage + 2
Text1(olage) = ""
Next
End Sub
Ravindra M.G.
Add to this Answer
Ask a Question
|
|