Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 17th, 2006, 09:47 AM
Authorized User
 
Join Date: Mar 2006
Location: London, , United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to use a run time variable as public

hi!
i m trying to use an integer "srchID" as publicly available variable.
whenever a user enters ID in a text box then my program will check if that id exists or not. if not it ignores, but if it exists it will assign the entered value val(txtEnterID.Text) = srchID
so i want to use this srchID in different forms to check functionality. i tried it as follows:


Private Sub cmdOk_Click() 'it is the main form where user enters ID
Dim sql, msg As String
Dim rs As New ADODB.Recordset
mdldb.dbconnect
Set rs = mdldb.conn.Execute("select StudentID from StudentProfile where StudentID = " & txtEnterID.Text & "")
If rs.EOF = True And rs.BOF = True Then
msg = MsgBox("This student doesn't exist", vbCritical)
Else
srchID = Val(" & txtEnterId.text &")
Load AccountsInfo 'i want to use srchID in this formAccountsInfo.Show
End If
End Sub

i defined srchID as Public, it doesn't show msg as the record doesn't exists but says either eof or bof is true or file is deleted.

Is there anyone who can help me?
thanx
Ana




Reply With Quote
  #2 (permalink)  
Old March 18th, 2006, 04:23 AM
Friend of Wrox
 
Join Date: Jan 2006
Location: Hardwar, Uttranchal, India.
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default

u can use this Variable declaration in Moudule

Public srchID As Integer

this variable will be accessible for all the Forms.

DPK..
Reply With Quote
  #3 (permalink)  
Old May 1st, 2006, 03:27 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I hope you have found your solution by now.

However, if you haven't... perhaps you can better describe your problem?



Woody Z http://www.learntoprogramnow.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
public article - public articledetails _keysersoze_ BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 8th, 2007 08:38 AM
Design-Time or Run-Time now ? ALGNET .NET Framework 2.0 1 July 31st, 2006 04:43 AM
difference b/w shared and public variable lgeetha VS.NET 2002/2003 1 March 4th, 2005 08:24 AM
Passing variable to a public variable Hudson40 Access VBA 2 February 25th, 2005 06:23 AM
How to reference Public Variable in Code Gino Liu Access VBA 2 June 18th, 2003 01:42 PM



All times are GMT -4. The time now is 07:04 PM.


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