Wrox Programmer Forums
Visual Basic 2010 General Discussion For any discussions about Visual Basic 2010 topics which aren't related to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2010 General Discussion 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 February 10th, 2013, 03:30 AM
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Feb 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Beginner question - Forms


I have read Beginning Visual Basic 2012, so you may say I know a little about Visual Basic. I have an simple application in mind, and for most of the questions I have the answers after reading this book. There is one thing I didn't understand.

All code examples referred to controls on the same Form (let's call it first page of the application).

If I want, for example, to have buttons on the first page (first form) with current time of some cities around the world, and when I click one of them to move on a dedicated form (let's call it second page), showing details for the respective city (to be mentioned here that I need this second page to have the same dimensions as the first one, so the user cannot feel the translation in both size and screen position), how to I implement this?

Thank you!
Old February 16th, 2013, 06:38 AM
Registered User
Join Date: Feb 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Showing an additional modal dialog is no big deal. All you have to do is add a new Form from the project->add menu and create an instance of it when you want to show it (typically in your button_click event procedures). This is a very rough implementation (not tested), assuming you have two forms named MasterForm and DetailForm added already at design time, write this code in the MasterForm:

Dim frmDetail as DetailForm

Private Sub Form_Load()
frmMaster.lblCity1.text = "New York"
frmMaster.lblCity2.text = "London"
frmMaster.lblCity3.text = "Paris"
frmMaster.lblCity4.text = "Munich"
End Sub

Private Sub lblCity1_Click(ByVal sender as Object, ByVal e as EventArgs)
frmDetail = New DetailForm()
frmDetail.txtCity = lblCity1.Text
frmDetail.txtTemperature = GetTemperature(lblCity1.Text)
frmDetail.txtCapital = GetCapital(lblCity1.Text)
End Sub

This is of course assuming that you already have the required labels and textboxes in the Master and DetailForms such as lblCity1, txtCapital, etc. and have also added the required methods to get the details such as GetCapital().

Similar Threads
Thread Thread Starter Forum Replies Last Post
Total complete beginner with forms? chmcke01 Beginning PHP 0 February 22nd, 2012 10:57 AM
Beginner question mike72 BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 1 September 11th, 2010 11:19 PM
a question from a beginner starnold BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 1 June 18th, 2009 10:36 AM
Beginner Question dkr72 Excel VBA 1 January 18th, 2005 09:37 AM
beginner question saudyonline General .NET 2 September 21st, 2004 01:56 AM

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