Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA 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 5th, 2012, 12:42 PM
Registered User
 
Join Date: Mar 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Displaying tabes in VB forms

I may be totally out of my depth, but I need to do something I haven't tried before and need a few pointers.

About 10 years ago, I used to program Excel macros quite happily. I also have a background in Pascal, but the finer points of VB are still a bit of a mystery to me, so bear with me.

I need to program a user interface screen that is linked to data (mainly text) in an Excel sheet. (It's quite possible that this would be easier in a DB, but it isn't and I don't have experience with Access programming either.) The client wants the screen to show rows of text which consists of a number of columns, eg:

==========================
Select indicators to examine:

Indicators NSP Policy Reform Market Forces Fortress World

Indicator 1 (text) (text) (text) (text) ?
Indicator 2 (text) (text) (text) (text) ?
Indicator 3 (text) (text) (text) (text) ?
Add new
indicator
==========================

As can be seen by the last row, there should be an option to add more rows. Also, at the end of each row is a check box. By leaving a box unchecked, the user can delete a row.

The question is: how do I program this using Excel VB?

I am currently thinking of using the Forms, but the only obvious controls I can insert are text boxes and check boxes. However, the form has to be able to add and delete rows and, even more complex, support more rows that space allows. Therefore, I'll have to be able to have scroll bars so the user can move up and down the table to see all rows. Will the 'Frame' control help with this?

I cannot believe that this sort of functionality hasn't already been programmed by somebody and I had hoped that such a function was already included in the VB library.

Maybe there are similar functions in HTML, but I've not used that before either.

Any suggestions anyone?
 
Old March 5th, 2012, 01:03 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Instead of Textboxes and Checkboxes you can try the Grid controls (DataGrid , Flexigrid or MSflexigrid etc). There are options to have one column as Checkbox and the remaining as Text fields when you define / during run time

There also some commercial Grid controls like Farpoint Spread etc which has even rich functionality

The only drawback of using these controls is - they should be distributed with the application if it is not available in the client machine

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old March 5th, 2012, 05:06 PM
Registered User
 
Join Date: Mar 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Shasur, many thanks. Mind you, I may have to struggle a bit before I can even get to the stage you recommend.

Believe it or not, I am struggling to get forms working. I have a full version of VB V4.0 and I've tried a couple of examples using the Form_Load command, but am getting nowhere. Trying to find out what's going on is impossible, given the size of the manuals.

I was trying to get a simple Combi Box loaded, but even something this simple failed. I know this is very simple and my error is likely to be equally simple, but I'm blowed if I can figure it out.
Code:
Private Sub Form_Load()

 ComboBox1.AddItem "Mozart"

 ComboBox1.AddItem = "Beethoven"

 ComboBox1.AddItem = "Strauss"

 ComboBox1.AddItem = "Deluis"

 ComboBox1.AddItem = "Brahms"

 ComboBox1.ListIndex = 2

End Sub
The manual actually said 'Combo1.AddItem', but that didn't work either. I'm presuming that there is something I have to do before I try loading the form, but I cannot see what it is.
 
Old March 6th, 2012, 01:12 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

You need to have it this way

Code:
ComboBox1.AddItem "Mozart"
 ComboBox1.AddItem "Beethoven"
 ComboBox1.AddItem "Strauss"
 ComboBox1.AddItem "Deluis"
 ComboBox1.AddItem "Brahms"
 ComboBox1.ListIndex = 2
Additem is a method and it accepts the Item as parameter

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with VB forms obscurum Visual Basic 2008 Essentials 3 August 11th, 2009 09:15 AM
Displaying Image in RSS Feed with Vb.Net hugh@kmcnetwork.com VB.NET 0 July 9th, 2007 09:09 PM
Displaying data fields from sub forms aRtware Access 5 May 8th, 2006 02:40 PM
Displaying Multiple forms on same php page wokoci PHP How-To 0 August 17th, 2004 06:53 AM
Displaying Xref-Tables in Datagrid in VB.NET Ron Howerton VB.NET 2002/2003 Basics 0 December 15th, 2003 02:52 PM





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