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 17th, 2006, 09:47 AM
Authorized User
 
Join Date: Mar 2006
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




 
Old March 18th, 2006, 04:23 AM
Friend of Wrox
 
Join Date: Jan 2006
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..
 
Old May 1st, 2006, 03:27 PM
Friend of Wrox
 
Join Date: May 2006
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





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





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