Results 1 to 4 of 4

Thread: important problems in visual basic

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2004
    Posts
    3

    Arrow important problems in visual basic

    Hello guys,

    Many greetings,

    I have some problem in visual basic, which are listed below : -

    1) How to create a function with N number of parameters?
    2)When array is created , it's intitial value is set from 0 , i want to start from 5 instead of zero.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Welcome to the forums.
    You mean like...
    VB Code:
    1. Private Function MyFunct(ByVal sParam1 As String, ByVal iParam2 As Integer, bParam3 As Boolean)
    2.    
    3.     'Your code here
    4.  
    5. End Function
    VB Code:
    1. Private Sub Form_Load()
    2.  
    3.     Dim arMyArray() As Long
    4.  
    5.     ReDim arMyArray(10) As Long
    6.     arMyArray(0) = 5
    7.  
    8. End Sub
    HTH
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    New Member
    Join Date
    Dec 2002
    Location
    Bucharest, Romania
    Posts
    8

    Thumbs up Re: important problems in visual basic

    Originally posted by harishpatel
    1) How to create a function with N number of parameters?
    2)When array is created , it's intitial value is set from 0 , i want to start from 5 instead of zero.
    You might try to use this:
    Code:
    Option Explicit
    
    Public Function Test(ByVal arg1 As Long, Optional ByVal arg2 As Long = 5) As Long
        Test = arg1 + arg2
    End Function
    
    Private Sub Form_Load()
        MsgBox Test(1)
    End Sub
    See more about Function Statement: Function Statement - Visual Basic for Applications Reference

    You should search allways MSDN online Library before asking help.

    Have fun!
    Maximus live 4ever
    ====================
    Try http://msdn.microsoft.com before ask for help.

  4. #4
    Addicted Member Bregalad's Avatar
    Join Date
    Jul 2000
    Location
    Oslo,Norway
    Posts
    183
    if N is unknown, you could also do it like this:

    VB Code:
    1. Private Sub Command1_Click()
    2.    MsgBox Test(1203, 123, 123)
    3. End Sub
    4.  
    5. Private Sub Command2_Click()
    6.    MsgBox Test(1203, 4873)
    7. End Sub
    8.  
    9. Private Function Test(ParamArray Params()) As Integer
    10.    Test = UBound(Params)
    11. End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width