String Array

I would like to format output to a property of a custom control I have made.  For instance I have a literal control in my control and when populated I want to check if it is longer than 30 characters long, if so, then go to the next space (as to not cut the word off) after the 30th character and place a <br /> tag in to place the next 30 characters on the next line.  So if there were 100 characters in a string, there would be 3 line breaks in the label.

I have the looping worked out to get the label populated but cannot get how to dymaically create the array based on the string lenth property and index of method. 


View Brenden Kehren's profile on LinkedIn
Remember to mark as answer if this post answered your question.
0
b471code3
5/4/2009 3:05:23 PM
asp.net.visual-basic.net 3721 articles. 0 followers. Follow

6 Replies
483 Views

Similar Articles

[PageSpeed] 44

When looping through your string array [100],

You can put an if statement like:

// check if the index of the character can be divided by 30 (meaning 31st/61st/91st character since index is 0 based) then move to the next line

If (i % 30 == 0) // % sign in VB.net = MOD

{ add </ br> here; }

Good Luck


Utomo IT Family
0
mutomo
5/4/2009 3:17:00 PM

Thanks mutomo, that works for part of my question although I want to get the string into an array of some type.  So this string "Please enter the physical address of the laboratory including department if applicable." has 87 characters including spaces.  So I want to count to 30 ("Please enter the physical addr") then skip to the next space and add that value into the array list.  Then start at that same space as we last stopped on and get the next 30 characters ("of the laboratory including de") then skip to the next space and add that value into the array list.  So my array items will be full values like this "Please enter the physical address", of the laboratory including department", "if applicable."  This particular array list will have 3 items in it. 

Make sense?


View Brenden Kehren's profile on LinkedIn
Remember to mark as answer if this post answered your question.
0
b471code3
5/4/2009 5:47:40 PM

Try this, the arrStr will have 3 items like you explain above.

Dim strToParse As String = "Please enter the physical address of the laboratory including department if applicable."

Dim str As String = ""

Dim arrStr As ArrayList = New ArrayList()

For i As Integer = 0 To strToParse.Length - 1 Step 1

If i Mod 30 = 0 And i > 0 Then

arrStr.Add(str)

str = ""

Else

str += strToParse(i)

End If

Next


Utomo IT Family
0
mutomo
5/4/2009 6:24:23 PM

Still doesn't do what I would like.  Your example cuts off in the middle of the word vs. going to the next space after.  Also, your example only puts one item in my array list.  There has to be an easier way to do this.  Just seems like so much work for so little.


View Brenden Kehren's profile on LinkedIn
Remember to mark as answer if this post answered your question.
0
b471code3
5/4/2009 7:26:28 PM

Sorry, I couldn't be much help, I guess I just don't have a clear idea of what you're trying to do. Hope fully, other will be able to help you better.

Good Luck


Utomo IT Family
0
mutomo
5/4/2009 7:38:04 PM

Well your first post got me closer but as I said still not what I want.  Here is my code block: 

    Public Property MessageText() As String
        Get
            Return lblMessage.Text
        End Get
        Set(ByVal value As String)
            If value.Length > 30 Then
                Dim strString As New StringBuilder()
                For i As Integer = 0 To value.Length - 1 Step 1
                    If i Mod 30 = 0 And i > 0 Then
                        strString.Append(value.IndexOf(" ", i).ToString())
                        strString.Append("<br />")
                    End If
                Next
                lblMessage.Text = strString.ToString()
            Else
                lblMessage.Text = value
            End If
        End Set
    End Property

 Say the value = "Please enter the physical address of the laboratory including department if applicable."

What I want is the label to display:

"Please enter the physical address
of the laboratory including department
if applicable."

Vs cutting off at 30, 60, 90, etc like so

"Please enter the physical addr
ess of the laboratory including
department if applicable."

My code block above gives me the correct numbers although I am not getting strings in return.  What simple step am I missing?


View Brenden Kehren's profile on LinkedIn
Remember to mark as answer if this post answered your question.
0
b471code3
5/4/2009 8:11:28 PM
Reply:

Similar Artilces:

Visual Studio .Net? Visual Basic .Net?
Okay, I admit it -- I know nothing about .Net. I'm a Visual Basic and ASP developer. DotNetNuke is my first tentative step into the whole ".Net Thing", and I'm looking for some advice... What do I really need to be able to make some modifications, or new modules for DotNetNuke? Do I need the full, THOUSAND DOLLAR Visual Studio .Net 2003 package, or can I get away with the HUNDRED DOLLAR Visual Basic .Net Standard package?Chameleon Systems, Inc. You can use webmatrix, available here for free. One of the drawbacks of webmatrix however is that it does not support code-be...

Visual Basic.NET or Visual Studio.NET?
OK, this has probably been asked before... I'm a student looking to cut my costs, and I can do this by just purchasing Visual Basic.NET as opposed to the fully-fledged Visual Studio.NET application. Of course, I'll only be able to program in VB, but that's fine with me. I wanted to know if all of the ASP.NET specific options are available, such as using a WYSIWYG editor? I'd also like to know if VB.NET has IntelliSense, or that's a specific option only available to Visual Studio.NET users. Thanks in advance. I'd have to believe that VB.Net has intellisense. What is the price d...

Visual Basic.NET or Visual Studio.NET? #2
I am currently using the Web Matrix to develop ASP.NET applications, but I am keep to upgrade to VS.NET. However, I can't justify spending $1,000 at the moment. I then found the MUCH cheaper "Visual Basic .NET 2003 Standard Edition" which is only $100. I have very little C# knowledge, and use Basic almost all the time. Would this be a good tool to use for web development? Does it support all the code behind stuff that VS users love so much? Thanks!! I use "VB.NET Standard Edition" and I'm happy with it. It has exactly the same features as Visual Studio.NET. Th...

Visual Basic .NET 2003 vs Visual Studio .NET 2003
Hi, If im going to be coding my ASP.NET in just VB.NET then would I be able to go for the cheaper option of buying Visual Basic .NET 2003 ?? - Carl S Yes.Starting with ASP.NET 2.0? Look at:Programming Microsoft Web Forms My Blog Are there any limitations if I was doing my ASP.NET with VB.NET in Visual Basic .NET 2003 than if I was using the full Visual Studio .NET 2003 ?? Or are the only advantages of Visual Studio .NET 2003 in that it supports more programming languages ?? - Carl S You should check the MS Web site, but I believe that, given an edition (Standard, Professional...

ADO.NET Programming in Visual Basic .NET
Has anyone read "ADO.NET Programming in Visual Basic .NET, Second Edition" by Steve Holzner (Author), Bob Howell (Author)? I am trying to working on a project and there are a few things that I need to tie up quickly in my web forms. Is this book a good one? karls------------------------------------'Old and wrinkled is not what I expected to become when I grew up!'...

C# Visual Basic.NET JScript.NET what should I choose ?
I'm just a beginner with programing ASP.NET web sistes. Unfortunatelly I don't know any of the languages supported by ASP. (By the time I programmed in DELPHI and SQL) So I should start to learn one of the languages. Could somebody help me to choose the language I should use ? Which and why ? Thanks in advance, Gonzi Use C# or VB.NET, which ever you are comfortable with. Go here to see sample of both in use http://samples.gotdotnet.com/quickstart/aspplus Ultimately, once you get more advanced, you'll really want to become comfortable with both languages. I ...

Converting Visual Basic 6 to Visual Basic .NET
Hi, I found this program that would get the mac address of a computer given its IP. I converted it into vb.net and it gave 2 errors. It said that I couldn't use "any" in declarations, so I found out what variable it was tryign to pass and changed the any to that data type. Now, the program will start in vb.net... but when I click the button, it returns the wrong mac address, while the one in vb6 returned the correct one.All you have to do is add 2 textboxes to the form and 1 button, dont change their names.::::::::::VB6 CODE::::::::::Option ExplicitPrivate Const NO_ERROR = 0Private Declare F...

Can I go from VS .NET 2003 to Visual Basic .NET 2003?
Hi, I just developed a commercial application using the trial version of Visual Studio .NET 2003.  My trial is about to expire.  I was hoping .NET 2.0 would be released by now, but that is obviously months away so I'm wondering if I could save a few hundred bucks by buying Visual Basic .NET 2003(around $110 i think) instead of having to buy Visual Studio .NET 2003, which I believe is up around $600 or so.   All my code is Visual Basic, so that's why I'm thinking that's all I need.  And it's mostly web development that I do if that matters.  T...

Visual C#.Net vs Visual Studio.Net
I have read in other posts a lot of people recommending Visual Studio.Net over the Web Matrix. My query is: why is there a £700 difference between VS.Net and Visual C#.Net? As a c# developer, I won't need any VB functionality. I also don't require Visual Source Safe, as projects are generally small and manageable. What features are lacking in Visual c#.net that justifies the price difference? Does it have Intellisense / Dubuggers / Compilers? These are the features that would make me pay for it instead of continuing with WM, but I need to know if tehre is serious functionality missin...

What are the diff. visual basic 6 and vb.net ? How to convert the VB6 project to vb.net proj ?
What are the diff. visual basic 6 and vb.net ? How to convert the VB6 project to vb.net proj ? with code and interface too. There are entire forums dedicated to the differences between the two, and to convert your projects you should try the upgrade wizard in Visual Studio....

Free Book
followup to grc.techtalk Free Book - Upgrading Microsoft Visual Basic 6.0 to Microsoft Visual Basic .NET http://msdn.microsoft.com/vbrun/staythepath/additionalresources/upgradingvb6/ ----------------------------------------------------------- Quote ----------------------------------------------------------- Upgrading Microsoft Visual Basic 6.0 to Microsoft Visual Basic .NET is is the complete technical guide to upgrading Visual Basic 6 applications to Visual Basic .NET, covering all upgrade topics from APIs to ZOrders. It shows how to fix upgrade issues with forms, language, data...

Can I install Visual Basic 6 on my machine which has VS.NET 2003 & VS.NET 2005?
I may have a need to use Visual Basic 6 for a legacy project in the near future.  I was wondering if I can install VB6 on my machine which already has VS.NET 2003 & VS.NET 2005 installed on it? I did not know if doing so would cause issues or not so thought I would ask before just leaping and doing.   Ira Richard Smith At one time i had to install Visual Basic 6 on my machine with VS.NET 2003 and had "NO" issues. I would suggest take a backup of your machine or a restore point before you proceed. Please post your experience. I am sure some one would appreci...

Net:Net:Net::LDAP::FAQ
------_=_NextPart_001_01C6429F.D89AA417 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, Net::LDAP Net::LDAPS Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, ....) password? I don't like to write the secret password to the perl file. Best regards Barbara Wilbert ------_=_NextPart_001_01C6429F.D89AA417-- Wilbert Barbara (CI/OSI) * wrote: > Hello, > > Net::LDAP > Net::LDAPS > > Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, > ......

Visual Studio .NET vs Visual Studio .NET 2002 or 2003?
As an admin, I'm working to determing what systems I need to update with the update on MS08-017, particularly with respect to Visual Studio .NET 2002 and 2003. I've got quite a few systems that appear to have Visual Studio .NET, no 2002 or 2003 mentioned when I view what's there in Add/Remove Programs. Is there a definitive way to determine if I have a 2002 or 2003 version?   sandy_wood:Is there a definitive way to determine if I have a 2002 or 2003 version? In add/remove programs it would indicate it VS2003 as Visual Studio 2003. Alternatively launch the applicatio...

visual studio.net 2003 conflict visual studio.net 2003
hello does visual studio.net 2003 makes conflict with visual studio.net 2003? thank you for the help and for the support No, the RTM version (I think this is true also for Beta 2), will work on the same machine without any problems./Fredrik Normén - fredrikn @ twitterMicrosoft MVP, MCSD, MCAD, MCTASPInsidersMy Blog i am shure 2003 doenst conflict with 2003 ;-)-Hanneshttp://www.preishuber.net http://weblogs.asp.net/hpreishuber the subject says "visual studio.net 2003 conflict visual studio.net 2003". is he talking about 2003 and 2005 ? pradeep_TP I think he is talking abo...

Web resources about - String Array - asp.net.visual-basic.net

‘Star Wars’ Rules Galaxy; What Else Is Up At The International Box Office
There’s been an awakening; I think we all felt that. But Star Wars ‘ global dominance this weekend doesn’t mean there weren’t other options out ...

Indonesian Air Force Begins Investigation In Plane Crash That Killed Two Experienced Pilots At Air Show ...
Indonesian Air Force has begun investigation into the crash of a military jet during aerobatic show. The crash killed both the pilots onboard. ...

Spain heads for coalition impasse after indecisive elections
The elections signal the end of two-party domination by the Popular Party and the Socialists.

Israel hit by rockets from Lebanon as tensions rise after Hezbollah's Samir Kantar killing
Katyusha missiles fired into Israel after air strike killed Hezbollah leader in Syria.

NYC mayor, police boss mark year since 2 officers were slain
Albuquerque’s source for local news and live streaming video online. KRQE reports on news, weather, traffic, investigations and sports for New ...

December 16 Gangrape Case: Delhi HC Refuses To Stop Juvenile’s Release
Decks were cleared for the release on Sunday of the juvenile convict in the horrific December 16, 2012 gangrape case with the Delhi High Court ...

China landslide leaves 59 missing, sparks gas explosion — Xinhua
Jamaica Observer China landslide leaves 59 missing, sparks gas explosion — Xinhua Jamaica Observer Rescuers look for survivors after a landslide ...

Sessions: Ted Cruz Critical to Blocking Amnesty
Senator Jeff Sessions, a Republican from Alabama, defended presidential candidate Ted Cruz at a rally last night in Alabama: "Let me tell you, ...

Shots fired in busy Wisconsin mall, police say
NBCNews.com Shots fired in busy Wisconsin mall, police say kjrh.com Copyright 2014 Scripps Media, Inc. All rights reserved. This material ...

Just-win Jets top Cowboys 19-16, keep heat on AFC contenders
Albuquerque’s source for local news and live streaming video online. KRQE reports on news, weather, traffic, investigations and sports for New ...

Resources last updated: 12/20/2015 11:57:34 PM