Solved

MsgBox Length

Posted on 2006-11-17
24
916 Views
Last Modified: 2012-05-05

Hi Experts

I have a very short question...
The maximun MsgBox Length is 1013 characters long,
So i was wondering if there is a way to make it longer.

For example:
everytime i try to add more than 2,000 characters to a msgbox, i get an error
any ide an how to do this without using NewLine String to the MsgBox message?

Thanks
0
Comment
Question by:Zak-R
  • 14
  • 6
  • 4
24 Comments
 
LVL 2

Author Comment

by:Zak-R
ID: 17964110

I can do this by using a TextBox
====================
Example:

MsgBox Text1
====================

But i don't like this methode
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17964164
you will have to create a new msgbox form yourself.
not other solution
0
 
LVL 8

Expert Comment

by:drydenhogg
ID: 17964182
When you say error, i'm not sure what error you are getting, I do not think you mean a runtime error, but that it fails to display all the characters, after 1013 the msgbox runs out of room. It doesnt generate a runtime error.

In terms of making a msgbox that could take far larger, first thing that comes to mind is sub classing the msgbox command, and using your own form to produce the functionality.

e.g.

Public Function Msgbox(prompt As String, Optional Buttons As VbMsgBoxStyle = vbOKOnly, Optional Title As String, Optional HelpFile As String, Optional Context As Long) As VbMsgBoxResult

' load a custom form here fill it in, behave like a msgbox

End Function
0
 
LVL 2

Author Comment

by:Zak-R
ID: 17964233

What if i try to split the msgbox, would this work line the NewLime?
===========================================

Now about this code:
'
Public Function Msgbox(prompt As String, Optional Buttons As VbMsgBoxStyle = vbOKOnly, Optional Title As String, Optional HelpFile As String, Optional Context As Long) As VbMsgBoxResult
'
MsgBox "can you tell me how to use it?"
'
End Function

0
 
LVL 2

Author Comment

by:Zak-R
ID: 17964242

I have two forms, 1 and 2, then in form 1 i add a buttom
then in that buttom i call the msgbox code, am i right?

0
 
LVL 8

Expert Comment

by:drydenhogg
ID: 17964259
The msgbox has a maximum length, no matter how much you split the line, there is a finite number of characters it can display. The newlines vbCrLF itself is being counted as two characters towards this finite limit as well.

In terms of the subclassed function, VB will give your MsgBox function priority over the inbuilt one (vba.interaction.msgbox) so any call to Msgbox would now use your custom one. If you only wanted to use it for specific instances, you would need to give it a name more like custom_msgbox

Back to the function,... you would create a new form, put approparite labels  on it, icons, buttons, respond to the parameters and display the text / buttons etc. Show this form modally, get the user's response and return the value.

Basically you are writing you own msgbox window, using a normal form.
0
 
LVL 2

Author Comment

by:Zak-R
ID: 17964311

I see...
I understand now...
But can you give me an example an how to use this custom msgbox?
I have everything in place but i can't get it to work properly, can you help me

thank you in advance

sorry but i am a novice in all of this :-)
0
 
LVL 2

Author Comment

by:Zak-R
ID: 17964546

---------------------------
Microsoft Visual Basic
---------------------------
Compile error:

Function call on left-hand side of assignment must return Variant or Object
---------------------------
OK   Help  
---------------------------

0
 
LVL 2

Author Comment

by:Zak-R
ID: 17964578

Hello, anybody there?

0
 
LVL 2

Author Comment

by:Zak-R
ID: 17964636

I create it an empty project, with formA and formB, formA as Startup form in formA:
Now what


0
 
LVL 2

Author Comment

by:Zak-R
ID: 17964661

I really hate when people just don't know the answer to a question,
and they just enter to the question and paste someone elses asnwer.

if you don't want to answer to my questions any more, at list let me know.

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17964705
>I really hate when people just don't know the answer to a question,
I really hate when people ask such generic questions and cannot understand that the volunteering "experts" might have lunch for example...

anyhow.

>I create it an empty project, with formA and formB, formA as Startup form in formA:
to open the second form (formB) from formA
formB.Show vbModal, me

to display the text, you have to put a method /property to the formb that accepts the text to display.
that method will have to resize the form as needed.
you will have to call that method/property before the call to fromB.Show

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17964714
Also, what kind of information are you trying to put to the msgbox that it is longer than 1000 characters?
0
 
LVL 8

Expert Comment

by:drydenhogg
ID: 17964737
Your are wrong to assume people do not know the answers, you just fail to take into account that most of the subscribers and people who do the answering have jobs to attend to. Until EE pays wages (which I do not wish it to do) you can appreciate our employers come before EE.

Given the level of VB knowledge you accept you have, subclassing the msgbox command is probably not the way to go, my personal judge is that it's not trivial for a novice level VB6 programmer to do.

On that basis, ignore subclassing, just display a model form with the information on that looks like the msgbox you wish to display. Angel has posted above how to show a form modally. On that form put a large label, and the appropriate buttons. As a solution it is far far from ideal.
0
 
LVL 2

Author Comment

by:Zak-R
ID: 17964919

Thanks angelIII
I have done it now...
But this don't look like an MsgBox
It looks more like an ordinary Form.

0
 
LVL 8

Expert Comment

by:drydenhogg
ID: 17964965
You need to set some properties of the form such as...
borderstyle = 1 - fixed single
Caption = title of the msgbox you wanted
minbutton = false
maxbutton = false
showintaskbar = false
startupposition = 1 - center owner
width = you have to decide that, cant see the form
height = same as width in that you must decide that.
icon = set to either your app icon or an appropriate one for what is being displayed.
0
 
LVL 2

Author Comment

by:Zak-R
ID: 17965168

I don't know what to say, all i know is that i feel that i have done this before.
To do this i don't really need such Custom_MsGBox Code, All i need is two forms
and call the Form two from Form1 like these => "Form2.Show vbModal", and thats it.
There is no need of the Custom_MsGBox Code.

Example:

Private Sub Command1_Click()
Form2.Show vbModal
End Sub

0
 
LVL 2

Author Comment

by:Zak-R
ID: 17965198

angelIII:
Also, what kind of information are you trying to put to the msgbox that it is longer than 1000 characters?

I want to display a message instrucction that is more than 1500 carracters long.

0
 
LVL 8

Expert Comment

by:drydenhogg
ID: 17965223
Correct, you do not need to do a subclass of the msgbox command (thus replacing it), that technique is more advanced and for replacing all msgboxes with custom ones.

For a single message being displayed there is no reason to do it, if you wanted to do this kind of length message regularily from your code, then it would be applicable since you would then want to re-use it.
0
 
LVL 2

Author Comment

by:Zak-R
ID: 17965449

Bad 35 points of investment :-)
This is not the answer i was specting for my question, but is only a 35 points question.
So i don't want to keep butthering anyone just for this dumb question. the only thing is,
i am trying to split this 35 points, but i think that option is not available with 35 points :-)
any suggestion?
0
 
LVL 8

Accepted Solution

by:
drydenhogg earned 35 total points
ID: 17965483
Give it to Angel, the day I worry about 35pts, is the day I give up on life.
0
 
LVL 2

Author Comment

by:Zak-R
ID: 17965599

I was just kidding drydenhogg :-)
But you know what?... this las post of yours, ulmust make me cry, well not cry
but ulmust about to have one tear in my eye :-)

Thank you drydenhogg
and of course thank you too Angel

0
 
LVL 2

Author Comment

by:Zak-R
ID: 17965622

Well, it looks like is time to start another two weeks to collect more points :-)
see you guys then, take carem and take every question easy.

bye

Zak-R
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17965980
>I want to display a message instrucction that is more than 1500 carracters long.
is the message dynamic?
if not, it would simply create the form exactly the way it is intended to be displayed to the user...
you can even easily add images to the form....
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now