Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
| Search | Today's Posts | Mark Forums Read
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro 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
  #1 (permalink)  
Old April 22nd, 2004, 05:28 AM
Authorized User
 
Join Date: Jul 2003
Location: Reading, Berkshire, United Kingdom.
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alex_read
Default Return a UDT from a function

Hi everyone, I can't find a word vba section so I'm posting here!!!

According to this page (http://msdn.microsoft.com/vba/Prodinfo/features.asp) this should be possible to do! I've got the following code I'm trying to use in a word vba class module (which has been made public):

------------------------------------------------------------------
Public Type udtSTYLEFONTINFO
    Bold As Boolean
    CharacterSpacing As Integer
    Colour As String
    Italic As Boolean
    Size As Integer
    SmallCaps As Boolean
    Underline As Boolean
End Type

Public Function GetStyleFontInfo(ByVal strStyleName As String) As udtSTYLEFONTINFO
    GetStyleFontInfo.bold = true
End Sub
-------------------------------------------------------------------

When I hit space after the as part of the function declaration, or try to write the .bold = true part, I get no intellisense for the custom udt appear. If I try to run the code, it highlights the "As udtSTYLEFONTINFO" part stating "User defined type not defined".

Um, HELP!!!!! please!

__________________
http://www.geocities.com/vbwig/
  #2 (permalink)  
Old April 23rd, 2004, 05:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Cardiff, , United Kingdom.
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

As far as I know class modules can not have public user defined types. You will need to create another class module called udtSTYLEFONTINFO and declare all the variables as Public. You will then need to use the Set keyword to create a new instance of the class before you set the variables:
Code:
Public Function GetStyleFontInfo(ByVal strStyleName As String) As udtSTYLEFONTINFO
    Set GetStyleFontInfo = New udtSTYLEFONTINFO

    GetStyleFontInfo.bold = true
End Sub
I hope that helps.

Regards
Owain Williams


Similar Threads
Thread Thread Starter Forum Replies Last Post
function return 'Nothing' problem srinuRocks ASP.NET 2.0 Basics 0 March 10th, 2005 10:32 AM
How do I make a function return a class? vertigo VB How-To 3 November 3rd, 2004 06:08 AM
How to return array value from a function nebpro BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 September 29th, 2004 12:14 PM
how to get a function to return a recordset object lcsgeek Classic ASP Databases 3 September 22nd, 2004 03:30 PM
public function execute = HELP! Return value ? davidkwang VS.NET 2002/2003 0 April 28th, 2004 12:18 PM





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