{"id":81,"date":"2011-09-15T02:58:51","date_gmt":"2011-09-14T21:28:51","guid":{"rendered":"http:\/\/www.automationrepository.com\/?p=81"},"modified":"2011-10-09T00:21:38","modified_gmt":"2011-10-08T18:51:38","slug":"msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead","status":"publish","type":"post","link":"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/","title":{"rendered":"MsgBox Ran Out of Space? Try DotNetFactory MessageBox instead."},"content":{"rendered":"<p style=\"text-align: justify;\">Did you know that the VBScript MsgBox that we usually use in QTP can display a string of maximum 1023 characters only? If the length of the string is more than 1023 characters, the MsgBox displays only the initial 1023 characters, leaving out the remaining ones.<!--more--><\/p>\n<p><span style=\"text-decoration: underline;\">Example:<\/span><\/p>\n<table style=\"border: 1px solid #000000;\" width=\"645\" border=\"0\">\n<tbody>\n<tr align=\"left\" bgcolor=\"#E0E0E0\">\n<td>\n<div style=\"font-family: 'Courier New',Courier,monospace;\">\n<div style=\"font-family: 'Courier New',Courier,monospace;\"><span style=\"font-family: 'Courier New',Courier,monospace; font-size: small; color: #000000;\">sMsg = <span style=\"color: #008000;\">&#8220;&#8221;<\/span><\/span><\/div>\n<div style=\"font-family: 'Courier New',Courier,monospace;\"><span style=\"color: #008000;\">&#8216;For Loop to create a string of 1021 characters<\/span><\/div>\n<div style=\"font-family: 'Courier New',Courier,monospace;\"><span style=\"color: #000080;\">For<\/span> i = 1 <span style=\"color: #000080;\">to<\/span> 1021<\/div>\n<div style=\"font-family: 'Courier New',Courier,monospace;\">\u00a0 sMsg = sMsg &amp; &#8220;*&#8221;<\/div>\n<div style=\"font-family: 'Courier New',Courier,monospace;\"><span style=\"color: #000080;\">Next<\/span><\/div>\n<\/div>\n<div style=\"font-family: 'Courier New',Courier,monospace;\">sMsg = sMsg &amp; <span style=\"color: #800000;\">&#8220;END&#8221;<\/span><\/div>\n<div style=\"font-family: 'Courier New',Courier,monospace;\"><span style=\"color: #008000;\">&#8216;Display the text in MsgBox<\/span><br \/>\nmsgbox sMsg<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div>\n<p>Now when we run the above code, we&#8217;ll get a popup box as displayed in the below image &#8211; <img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"VBScript MsgBox Maximum Length\" src=\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/msgbox-1023.png\" alt=\"VBScript MsgBox Maximum Length 1023 Characters\" width=\"527\" height=\"189\" \/><\/p>\n<\/div>\n<div style=\"text-align: justify;\">\n<p>Here, you can observe that since the length of the string was 1024 characters, the message box skipped the last character &#8216;D&#8217; in order to display 1023 characters.<\/p>\n<\/div>\n<div style=\"text-align: justify;\">\n<p>The next obvious question that comes in our minds is &#8211; Is there any other way using which we can display more than 1023 characters in QTP using a message box? Is there any workaround? And the answer is.. YES!!<\/p>\n<\/div>\n<div style=\"text-align: justify;\">\n<p>Although the VBScript MsgBox displays only maximum 1023 characters in a popup box, you can use Microsoft&#8217;s <strong>Windows Forms &#8216;MessageBox&#8217;<\/strong> in QTP to display strings having much more characters. QTP provides a utility object named &#8220;DotNetFactory&#8217;, using which, you can access Windows Forms MessageBox and many other Form objects in your script.<\/p>\n<\/div>\n<div style=\"text-align: justify;\"><span style=\"text-decoration: underline;\">Example:<\/span><\/div>\n<div style=\"text-align: justify;\">\n<table width=\"645\" border=\"0\">\n<tbody>\n<tr align=\"left\" bgcolor=\"#E0E0E0\">\n<td>sMsg = <span style=\"color: #800000;\">&#8220;&#8221;<br \/>\n<\/span><br \/>\n<span style=\"color: #008000;\">&#8216;For Loop to create a string of say, 3000 characters<\/span><br \/>\n<span style=\"color: #0000ff;\">For<\/span> i = 1 <span style=\"color: #0000ff;\">to<\/span> 3000<br \/>\nsMsg = sMsg &amp; <span style=\"color: #800000;\">&#8220;*&#8221;<\/span><br \/>\n<span style=\"color: #0000ff;\">Next<br \/>\n<\/span><br \/>\nsMsg = sMsg &amp; <span style=\"color: #800000;\">&#8220;END&#8221;<br \/>\n<\/span><br \/>\n<span style=\"color: #008000;\">&#8216;Display the text in Windows Forms MessageBox<\/span><br \/>\nSet MsgBox = DotNetFactory.CreateInstance(<span style=\"color: #800000;\">&#8220;System.Windows.Forms.MessageBox&#8221;<\/span>, <span style=\"color: #800000;\">&#8220;System.Windows.Forms&#8221;<\/span>)<br \/>\nMyMsgBox.Show sMsg<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div>\n<p>If you run the above code, you get a popup message as shown below &#8211;<\/p>\n<div style=\"width: 647px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" title=\"Windows Forms MessageBox in QTP using DotNetFactory\" src=\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/dotnetfactory-msg.png\" alt=\"Windows Forms MessageBox displaying more than 1023 characters\" width=\"637\" height=\"475\" \/><p class=\"wp-caption-text\">DotNetFactory Windows Forms MessageBox in QTP<\/p><\/div>\n<\/div>\n<div>\n<p>Here you can see that the text &#8216;END&#8217; is completely visible in the MessageBox even after it displays a string of 3000 asterisks (*) . This shows that you can use Windows Forms MessageBox whenever you want more than 1023 characters to be displayed in your popup box.<\/p>\n<\/div>\n<\/div>\n<div>\n<p><em><span style=\"text-decoration: underline;\">Note:<\/span> Even though you can display thousands of characters in a popup box using\u00a0 Windows Forms MessageBox, but it really doesn&#8217;t make sense to display more than 8K-9K characters in a MessageBox. This is because if the characters exceed a certain limit, the boundaries of the message box would exceed that the size of the screen rendering many portions of the text unreadable.<\/em><\/p>\n<p>Happy Reading&#8230; :&#8211;)<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<div style=\"font-family: Verdana,sans-serif; border: 1px solid #C8B560; padding: 3mm; background: #FFF8C6; text-align: center;\">\n<p>If you enjoyed this article, you can join our blog to get free email updates directly in your inbox.<\/p>\n<form style=\"text-align: center;\" action=\"http:\/\/feedburner.google.com\/fb\/a\/mailverify\" method=\"post\" onsubmit=\"window.open('http:\/\/feedburner.google.com\/fb\/a\/mailverify?uri=automationrepository\/feeds', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true\" target=\"popupwindow\"><input style=\"width: 160px; height: 24px;\" onfocus=\"if (this.value == 'Enter Your Email Address') {this.value = '';}\" onblur=\"if (this.value == '') {this.value = 'Enter Your Email Address';}\" type=\"text\" value=\"Enter Your Email Address\" \/> <input type=\"hidden\" name=\"uri\" value=\"automationrepository\/feeds\" \/> <input type=\"hidden\" name=\"loc\" value=\"en_US\" \/> <input type=\"submit\" value=\"Subscribe\" \/><\/p>\n<p style=\"text-align: justify;\">\n<\/form>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Did you know that the VBScript MsgBox that we usually use in QTP can display a string of maximum 1023 characters only? If the length of the string is more than 1023 characters, the MsgBox displays only the initial 1023 characters, leaving out the remaining ones.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[27,28],"class_list":["post-81","post","type-post","status-publish","format-standard","hentry","category-qtp-concepts","tag-dotnetfactory","tag-msgbox"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>MsgBox Ran Out of Space? Try DotNetFactory MessageBox instead. - XX<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anish Pillai\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/\",\"name\":\"MsgBox Ran Out of Space? Try DotNetFactory MessageBox instead. - XX\",\"isPartOf\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/msgbox-1023.png\",\"datePublished\":\"2011-09-14T21:28:51+00:00\",\"dateModified\":\"2011-10-08T18:51:38+00:00\",\"author\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/#primaryimage\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/msgbox-1023.png\",\"contentUrl\":\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/msgbox-1023.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.automationrepository.com\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MsgBox Ran Out of Space? Try DotNetFactory MessageBox instead.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#website\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/\",\"name\":\"XX\",\"description\":\"\\r\\nasas\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.automationrepository.com\/wordpress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20\",\"name\":\"Anish Pillai\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g\",\"caption\":\"Anish Pillai\"},\"description\":\"Find more about Anish Pillai on Google+\",\"sameAs\":[\"http:\/\/www.automationrepository.com\"],\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/author\/anish\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MsgBox Ran Out of Space? Try DotNetFactory MessageBox instead. - XX","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/","twitter_misc":{"Written by":"Anish Pillai","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/","url":"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/","name":"MsgBox Ran Out of Space? Try DotNetFactory MessageBox instead. - XX","isPartOf":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/#primaryimage"},"image":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/#primaryimage"},"thumbnailUrl":"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/msgbox-1023.png","datePublished":"2011-09-14T21:28:51+00:00","dateModified":"2011-10-08T18:51:38+00:00","author":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20"},"breadcrumb":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/#primaryimage","url":"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/msgbox-1023.png","contentUrl":"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/msgbox-1023.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.automationrepository.com\/wordpress\/2011\/09\/msgbox-ran-out-of-space-try-dotnetfactory-messagebox-instead\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.automationrepository.com\/wordpress\/"},{"@type":"ListItem","position":2,"name":"MsgBox Ran Out of Space? Try DotNetFactory MessageBox instead."}]},{"@type":"WebSite","@id":"https:\/\/www.automationrepository.com\/wordpress\/#website","url":"https:\/\/www.automationrepository.com\/wordpress\/","name":"XX","description":"\r\nasas","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.automationrepository.com\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20","name":"Anish Pillai","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g","caption":"Anish Pillai"},"description":"Find more about Anish Pillai on Google+","sameAs":["http:\/\/www.automationrepository.com"],"url":"https:\/\/www.automationrepository.com\/wordpress\/author\/anish\/"}]}},"_links":{"self":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/comments?post=81"}],"version-history":[{"count":40,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/81\/revisions"}],"predecessor-version":[{"id":517,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/81\/revisions\/517"}],"wp:attachment":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/media?parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/categories?post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/tags?post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}