Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

visual basic functions

Posted on 2004-10-12
6
Medium Priority
?
196 Views
Last Modified: 2010-04-17
hi there, I've created a function that should return  results on a datalist object:(here are the codes):
======
Public Function myactive_users(current_list As datalist)
   
    Adodc1.ConnectionString = "DSN=mydsn"
    Adodc1.RecordSource = "select distinct myUsers from myTable  order by Myuser"
    Adodc1.Refresh
   
    current_list.DataField = "myUsers"
    current_list.ListField = "myUsers"
   
    Set current_list.DataSource = Adodc1
    Set current_list.RowSource = Adodc1
   
End Function
=========
Now, when I call this function to populate results on another datalist, the compiler tells me  "error mismach". This is what I am doing: myactive_users(this_datalist1)
Anybody can help on how to do that properly?
I will apreciate ur help.
F.

0
Comment
Question by:Francisco_M
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 12

Expert Comment

by:farsight
ID: 12292714
I don't fully understand your issue.  But this might get you started ...

[VB.NET]
Public Function myactive_users(current_list As datalist) As ???_What_Type_???

   Return ???_What_Object_Of_The_Given_Type_???    
End Function

In VB6, you'd use:
  myactive_users = ???_What_Object_Of_The_Given_Type_???
instead of the Return statement.
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 240 total points
ID: 12293274
On which line do you get the error?

Remove parenthesis or add a CALL statement like this:
myactive_users this_datalist1
call myactive_users(this_datalist1)

Also add the Recordset to these 2 lines:
    Set current_list.DataSource = Adodc1.Recordset
    Set current_list.RowSource = Adodc1.Recordset
0
 

Expert Comment

by:huyntminh
ID: 12294337
I agree with emoreau, and remember, your datalist object "this_datalist1" must be initialized before passing it to the function myactive_users.
Hope u sucess.
0
 

Author Comment

by:Francisco_M
ID: 13542752
THANKS emoreau,
It worked!
Sorry to reply so late!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Simple Linear Regression
Starting up a Project

662 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question