-
Mar 26th, 2006, 11:00 AM
#1
Thread Starter
Lively Member
maximum length for string in VB6
Hi
If I declare a string in vb6, and don't specify a maximum value, like this:
1. What is the maximum amount of characters which can be held in this string?
2. If I do not specify a maximum - then does this waste memory?
many thanks
langals
-
Mar 26th, 2006, 11:13 AM
#2
Re: maximum length for string in VB6
1) approx 2 billion characters
2) No.
-
Mar 26th, 2006, 11:52 AM
#3
Re: maximum length for string in VB6
(1) I read somewhere, it is 2GB
(2) I think it will waste space only if you specify the maximum limit, otherwise not.
Pradeep
-
Mar 26th, 2006, 12:21 PM
#4
Thread Starter
Lively Member
Re: maximum length for string in VB6
Hi guys
thanks for the replies. It must be something else in my code with is causing problems then.
langals
-
Mar 26th, 2006, 02:27 PM
#5
Frenzied Member
Re: maximum length for string in VB6
langals:
Greeting to you there in South Africa.
It might be easier for someone to help you if you posted some or all of your code.
Then we could see just what is happening or not happening and probably find a solution for you.
Good Luck
Last edited by AIS4U; Mar 26th, 2006 at 02:39 PM.
-
Mar 26th, 2006, 04:33 PM
#6
Re: maximum length for string in VB6
A VB variable-length string can only in theory be 2GB in size, it's actual maximum size is depending on available virtual memory which is also limited to 2GB for the entire application. But since VB stores the string in unicode format it means that it can only contain 1GB of text.
Also the string takes up 12 bytes apart from the actual text, so even an empty string takes up 12 bytes of memory.
A fixed length string is limited to 64KB in length.
-
Mar 26th, 2006, 04:39 PM
#7
Re: maximum length for string in VB6
I thought virtual memory was maxed at 4095 kbs?
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
-
Mar 26th, 2006, 04:47 PM
#8
Re: maximum length for string in VB6
4095 kbs? That's a transfer speed... . But you are correct Rob. All 32-bit applications runs in a separate virtual machine and each of those are assigned 4GB of virtual memory. However 2 of those 4GB are used by the OS itself and the other 2 can be freely used by the application.
-
Mar 26th, 2006, 05:52 PM
#9
Re: maximum length for string in VB6
Thanks for the confirmation JA. Windows wont let you enter in anything larger then 4095 so its 1 byte short of 4 GBs.
I'll remember that 1/2 is used by Windows.
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
-
Mar 26th, 2006, 06:01 PM
#10
Re: maximum length for string in VB6
Actually it's not 1 byte less it's just that the memory area is zero based.
-
Mar 26th, 2006, 06:04 PM
#11
Re: maximum length for string in VB6
Misleading but ok.
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
-
Mar 26th, 2006, 06:09 PM
#12
Re: maximum length for string in VB6
-
Mar 26th, 2006, 06:13 PM
#13
Re: maximum length for string in VB6
"Total paging size for all drives: 4095 MBs"
If its zero based then you could display "0 MBs" but still actually have 1 MB. Although, I do know the minimum is 8 MBs.
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
-
Mar 26th, 2006, 06:43 PM
#14
Re: maximum length for string in VB6
Oh, you're talking about the size of the paging file... Well, the paging on the drive is used for swapping of memory but it's not actually the same as the virtual memory. 4GB is given to every process you are running and if the physical memory is not enough then paging will occur (well, you know all of that).
-
Mar 26th, 2006, 07:00 PM
#15
Fanatic Member
Re: maximum length for string in VB6
Maybe this thread can help..i had the same problem/doubt
http://www.vbforums.com/showthread.php?t=372024
With special attention to what Joacim Andersson wrote..
-
Oct 27th, 2014, 05:35 AM
#16
Lively Member
Re: maximum length for string in VB6
In my opinion you can easily test it:
Code:
Dim T As Long
Dim BB As String
For T = 1 To 2000000
BB = BB + "x"
Next T
Debug.Print Len(BB)
Stop
-
Oct 27th, 2014, 06:08 AM
#17
Re: maximum length for string in VB6
This thread is 8 years old. Thread closed!
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
|