devxlogo

Creating Public Methods vs. Using Show Directly

Creating Public Methods vs. Using Show Directly

Question:
The program I am writing has two menu items for displaying say, autoexec.bat and config.sys respectively. I would like to make it so thatthey only need to call a form which contains a richtext box to display the files, but I didn’t knowhow to tell the form what file to display upon invoking it (using show method) from the two menus.

Answer:
Actually, since you’re using VB 4.0, you can create a public method on your form that can be used instead of the Show method. For instance:In the file display form:

Public Sub ShowFile(sFilename as String)           Me.Show   ‘ will display form   ‘ Code to load file into text box or whatever goes hereEnd Sub
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist