|
-
Aug 9th, 2004, 06:23 AM
#1
Thread Starter
New Member
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.
-
Aug 9th, 2004, 10:37 AM
#2
Welcome to the forums.
You mean like...
VB Code:
Private Function MyFunct(ByVal sParam1 As String, ByVal iParam2 As Integer, bParam3 As Boolean)
'Your code here
End Function
VB Code:
Private Sub Form_Load()
Dim arMyArray() As Long
ReDim arMyArray(10) As Long
arMyArray(0) = 5
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Aug 13th, 2004, 03:24 AM
#3
New Member
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.
-
Aug 13th, 2004, 08:42 AM
#4
Addicted Member
if N is unknown, you could also do it like this:
VB Code:
Private Sub Command1_Click()
MsgBox Test(1203, 123, 123)
End Sub
Private Sub Command2_Click()
MsgBox Test(1203, 4873)
End Sub
Private Function Test(ParamArray Params()) As Integer
Test = UBound(Params)
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|