|
-
Sep 8th, 2008, 11:11 AM
#1
Thread Starter
Member
help converting variable declaration (VB2005)
Hail to All,
I need help is converting a variable declaration. In VB 6 I used to be able to create a variable like the following.
Private WatchingKey(1 to 26) as Boolean
How do I do this now in 2005 as this no longer works.
Thanks for all your help.
-
Sep 8th, 2008, 11:21 AM
#2
Fanatic Member
Re: help converting variable declaration (VB2005)
I am not sure what is that supposed to do. Is it an array? of 26 elements starting with 1 instead of zero?
The simplest thing would be
vb Code:
Private WatchingKey(25) As Boolean
which will give you 0 - 25 (or 26 elements)
-
Sep 8th, 2008, 11:36 AM
#3
Thread Starter
Member
Re: help converting variable declaration (VB2005)
Thanks. Just wanted it to start at 1 not 0 but just have to add an extra elemlnt.
-
Sep 8th, 2008, 04:50 PM
#4
Re: help converting variable declaration (VB2005)
Arrays all start with 0 in .NET. Just add a +1 to the variable you are using as such.
Private WatchingKey(25) As Boolean
Dim i as integer = 0
'...
WatchingKey(i + 1) = "Blah"
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 
-
Sep 8th, 2008, 07:39 PM
#5
Re: help converting variable declaration (VB2005)
 Originally Posted by Mythos44
Thanks. Just wanted it to start at 1 not 0 but just have to add an extra elemlnt.
Don't ever add an extra element to arrays like that. As Rob suggests, arrays are zero-based and you should use them as such. There's never a need for a hack like that. It's all handled smoothly with properly written code.
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
|