Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 4th, 2008, 12:52 PM
Registered User
 
Join Date: Feb 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do you use Functions in VB?

I am seriously new to VB6. I am trying to create an email notification system where a user can go in and create a message along with the people he wants to send the msg to. I am saving the data in 2 tables in Access - an Emails table for storing the msg and an EmailTo table for storing the people for each message.

I put a timer on my form to check for every minute if there is a msg to send out. It goes and looks at the Emails table for the schedule weekday and the time and if its ready to send out, it goes and gets the names that are attached to that particular msg. This is where my issue/problem comes in. Functions are new to me. I have a function called GetNamesList (lngRecID As Long) and in it, I open a recordset for all the records that = the RecID and I loop through until I get all the names and add ";" to each name and then subtract the last ";" from the results.

I am not sure I know how to call that function and I don't know what its supposed to pass back to me b/c I'm trying to set it = to a string. strSendTo = GetNamesList and it doesn't like that.

any help?

 
Old March 4th, 2008, 01:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there.. I don't understand how you build the rest of the system without using functions, or maybe you are just confused. You used functions in vb all the time.. if you open a recordset, somewhere you have to open a database, and in all that process, you called functions (inside objects or outside of them)...

Anyway.. you call that function using:
Code:
GetNamesList(?)
where ? is a number, but I can't tell you witch number you need, probably a key from email table...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old March 4th, 2008, 05:12 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I had a lot of confusion myself when I was staring out about how to enter a function. I could write it, but how to get it to be run?

There are a variety of ways actually. You can write a function, and use it in a query. Then it will be run when the query is run.

You can run it through some event on a form. (There are beaucoup events; some are: the click event of a button, the load event of the from , the resize event of the form, the mouse events of the form or of a control, in response to keydown, keyup and keypress, and on and on.

That function you described would be called in code with
Code:
    Dim SomeReceiverForValue As <some type>
    SomeReceiverForValue = GetNamesList(RecSet!ID)
    The parens tells VBA that this is a function. If you had written a sub, it would be called instead with:
Code:
    GetNamesList RecSet!ID  ' no return val, no parens





Similar Threads
Thread Thread Starter Forum Replies Last Post
acessing DLL functions in VB Scripting seeekvb VBScript 5 January 15th, 2007 06:58 PM
How to access functions of Dll created in VC in VB seeekvb BOOK: Beginning ASP.NET 1.0 4 January 15th, 2007 06:58 PM
Inline functions in VB.NET ashu_from_india VS.NET 2002/2003 2 February 24th, 2005 09:54 AM
AS Clause on Functions VB.Net Duncan VS.NET 2002/2003 1 May 1st, 2004 08:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.