Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > commit filename to memory for use with all forms


Reply
 
Thread Tools Display Modes
  #1  
Old 04-15-2003, 12:35 PM
ljmb34 ljmb34 is offline
Newcomer
 
Join Date: Apr 2003
Posts: 18
Default commit filename to memory for use with all forms


Q: I have a Form1 which opens FileName "Example.xls" an Excel file to input. I minimize Form1 and open Form2, however FileName "Example.xls" only resides on Form1. How do I automatically associate Form2 with FileName on Form1 which is the already openend Excel File for input. My thoughts are with the open common dialog box. As all i am trying to perform is: On Form1 the Open dialog Box container is set to "Example.xls" Ie: dlgFileops.Filename = "Example.xls", so on Form2 the dlgFileops.Filename = "Example.xls" automatically without input from user.

Any input on the subject would be appreciated.
Reply With Quote
  #2  
Old 04-15-2003, 12:37 PM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
Default

Declare the filename Public in a regular module (.BAS)
or reference it from your form like this:
Form1.CmDlg.Filename
.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 04-15-2003, 12:39 PM
VBJoe's Avatar
VBJoe VBJoe is offline
Village VB Idiot

* Expert *
 
Join Date: Jan 2003
Location: Idaho
Posts: 1,850
Default

As long as you haven't Unloaded Form1, you can call it like this from Form2:
Code:
Private Sub Form_Load() Dim Form2FileName As String Form2FileName = Form1.CmDlg.FileName 'Do whatever here with the file End Sub
Reply With Quote
  #4  
Old 04-15-2003, 12:46 PM
VBDude VBDude is offline
Centurion
 
Join Date: Jun 2001
Location: New York
Posts: 114
Default

or if you want to be able to access the file name from any form (whether it's loaded or not), try something like this:

'in form1:
open app.path &"\filename.tmp" for output as #1
print #1, FILENAME 'this would be the "Example.xls"
close #1

'then to get the file name:
dim filename as string
open app.path & "\filename.tmp" for input as #1
line input #1, filename 'this variable now has the name of the file you want
close #1
__________________
nothing's really wrong... it's just not quite right
Reply With Quote
  #5  
Old 04-15-2003, 01:00 PM
ljmb34 ljmb34 is offline
Newcomer
 
Join Date: Apr 2003
Posts: 18
Default I was head there but VBJoe had what I was looking for

Quote:
Originally Posted by VBDude
or if you want to be able to access the file name from any form (whether it's loaded or not), try something like this:

'in form1:
open app.path &"\filename.tmp" for output as #1
print #1, FILENAME 'this would be the "Example.xls"
close #1

'then to get the file name:
dim filename as string
open app.path & "\filename.tmp" for input as #1
line input #1, filename 'this variable now has the name of the file you want
close #1



Your above example was going to be my last hope so to speak, however I was concerned on keeping the whole program a simple container with the only inputs directed on Excel.

VBJoe had what I was looking for. A simple call routine. It works great!

Thanks go to all who help out newbies...

I was also looking at class modules vs standard modules but I havn't got a clue on how to figure them out. My thought was to write the filename to memory and not to a physical file. However, I knew it was there, what I could not figure out was how to access it.

Thanks for your ideas...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get reading from Serial COM1 port salsa Communications 57 06-15-2004 05:22 AM
commited filename to memory ljmb34 General 3 04-14-2003 04:01 PM
DirectX (distribute) jeremyrharris DirectX 12 04-04-2003 12:38 PM
forms & memory Rockinron General 4 02-20-2003 06:00 AM
Does Windows allocate memory for VB Programs efficiently? Draco97 Tech Discussions 15 12-22-2002 03:22 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->