VB.NET ASP.NET String Examples – String Examples ASP.NET VB.NET
"I tried to learn .NET by taking boot camp classes that cost me $6,000. After taking the classes, I discovered tons of free (and very cheap) videos on the internet created by experts in the field. I found the videos to be much better than the classrooms. The videos were presented by Microsoft presenters that knew the material backwards and forwards, and they were much cheaper and better than the classroom teachers. I have spent the last three years organizing and hunting down the videos for my own use and decided that all could benefit by sharing what I found." - Wade Harvey
Click Here for Free 24 hour pass to lynda.com.
I AM VERY EXCITED ABOUT THIS AMAZING NEW DISCOVERY
Over 40,000 Top-Notch Video Tutorials (or 3,452 hours) on Lynda.com
I had stumbled across Lynda.com many times before, but never stopped to try it out. I recently took the plunge and started using Lynda.com to help me improve my javascript skills (See Javascript Essential Training 2007 by Dori Smith). It has revolutionized my understanding of the language! I love the fact that the exercise files allow you to follow along in real time with what the instructor is saying. Learning by doing is an extremely powerful technique. I have to give the site an A+ for both quality and content.
I am planning on using Lynda Videos to help me improve in:

Looking for premium .NET Training Videos? The best premium .NET Videos that I have found are at Learn Visual Studio. Those videos are only about 50 cents per hour, as compared to $25 per hour that other sites charge!
LearnVisualStudio is currently having a 25% off sale ($50 savings) and giving away a free membership to TrainingSpot ($60 value) when LVS Lifetime Membership is purchased.


Limited Time Offer: Free Lifetime Membership to Progress Monitor ($24.95 value) when you purchase any membership at Learn Visual Studio, Lynda Videos or any hosting account at DiscountASP - just forward order confirmation to harvey007@sbcglobal.net
I had stumbled across Lynda.com many times before, but never stopped to try it out. I recently took the plunge and started using Lynda.com to help me improve my javascript skills (See Javascript Essential Training 2007 by Dori Smith). It has revolutionized my understanding of the language! I love the fact that the exercise files allow you to follow along in real time with what the instructor is saying. Learning by doing is an extremely powerful technique. I have to give the site an A+ for both quality and content.
I am planning on using Lynda Videos to help me improve in:
- HTML
- CSS
- Classic ASP
- .NET (included in ASP section)
- AJAX
- Silverlight (in Microsoft Section)
- SharePoint (in Microsoft Section)
- Web Design
- Blogging
- SEO
- and much more

Looking for premium .NET Training Videos? The best premium .NET Videos that I have found are at Learn Visual Studio. Those videos are only about 50 cents per hour, as compared to $25 per hour that other sites charge!
LearnVisualStudio is currently having a 25% off sale ($50 savings) and giving away a free membership to TrainingSpot ($60 value) when LVS Lifetime Membership is purchased.


Limited Time Offer: Free Lifetime Membership to Progress Monitor ($24.95 value) when you purchase any membership at Learn Visual Studio, Lynda Videos or any hosting account at DiscountASP - just forward order confirmation to harvey007@sbcglobal.net
VB.NET ASP.NET String Examples – String Examples ASP.NET VB.NET
Purpose: – Illustrates using String Properties and String Methods in VB.NET ASP.NET.
Prerequistes:
- Install Visual Web Developer 2008
- Install SQL Server Express
- Download Northwind and Pubs Databases
- Attach Northwind Database to Databases in Sql Express
- Attach pubs Database to Databases in Sql Express
Notes:
- You can build your own library of syntax examples by using same web site over and over and just add new web forms to it.
Instructions:
- Use Visual Web Developer 2008
- Create new web site;
- Click File/New Web Site
- Select ASP.NET Website Template
- Select Visual Basic for Language
- name of Web Site could be VBNET_ASPNET_Syntax.
- Add New folder named "LanguageBasics"
- Right-click project name in solution explorer;
- add new folder;
- name of folder could be: LanguageBasics
- Add Web Form Named String to LanguageBasics folder
- Right-click LanguageBasics folder;
- add new item;
- Select Web Form
- Check place code behind in separate file
- Web Form name could be String
- Click on copy code in code below to copy code into web form String.aspx
- Click on copy code in second set of code below to copy code into code-behind String.aspx.vb
- Right-click on String.aspx in solution explorer and select view in browser
Step 1: Click on Copy Code to Cut-n-paste code into String.aspx
| XML | | copy code | | ? |
| 01 | |
| 02 | < %@ Page Language="VB" AutoEventWireup="false" CodeFile="String.aspx.vb" Inherits="LanguageBasics_String" %> |
| 03 | |
| 04 | < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 05 | |
| 06 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 07 | <head runat="server"> |
| 08 | <title></title> |
| 09 | </head> |
| 10 | <body> |
| 11 | <form id="form1" runat="server"> |
| 12 | <div> |
| 13 | <asp :Label ID="Label1a" runat="server" Text="Label"></asp><br /> |
| 14 | <asp :Label ID="Label1" runat="server" Text="Label"></asp><br /><br /> |
| 15 | <asp :Label ID="Label2a" runat="server" Text="Label"></asp><br /> |
| 16 | <asp :Label ID="Label2" runat="server" Text="Label"></asp><br /><br /> |
| 17 | <asp :Label ID="Label3a" runat="server" Text="Label"></asp><br /> |
| 18 | <asp :Label ID="Label3" runat="server" Text="Label"></asp><br /><br /> |
| 19 | <asp :Label ID="Label4a" runat="server" Text="Label"></asp><br /> |
| 20 | <asp :Label ID="Label4" runat="server" Text="Label"></asp><br /><br /> |
| 21 | <asp :Label ID="Label5a" runat="server" Text="Label"></asp><br /> |
| 22 | <asp :Label ID="Label5" runat="server" Text="Label"></asp><br /><br /> |
| 23 | |
| 24 | <asp :Label ID="Label6a" runat="server" Text="Label"></asp><br /> |
| 25 | <asp :Label ID="Label6" runat="server" Text="Label"></asp><br /><br /> |
| 26 | <asp :Label ID="Label7a" runat="server" Text="Label"></asp><br /> |
| 27 | <asp :Label ID="Label7" runat="server" Text="Label"></asp><br /><br /> |
| 28 | <asp :Label ID="Label8a" runat="server" Text="Label"></asp><br /> |
| 29 | <asp :Label ID="Label8" runat="server" Text="Label"></asp><br /><br /> |
| 30 | <asp :Label ID="Label9a" runat="server" Text="Label"></asp><br /> |
| 31 | <asp :Label ID="Label9" runat="server" Text="Label"></asp><br /><br /> |
| 32 | <asp :Label ID="Label10a" runat="server" Text="Label"></asp><br /> |
| 33 | <asp :Label ID="Label10" runat="server" Text="Label"></asp><br /><br /> |
| 34 | |
| 35 | <asp :Label ID="Label11a" runat="server" Text="Label"></asp><br /> |
| 36 | <asp :Label ID="Label11" runat="server" Text="Label"></asp><br /><br /> |
| 37 | <asp :Label ID="Label12a" runat="server" Text="Label"></asp><br /> |
| 38 | <asp :Label ID="Label12" runat="server" Text="Label"></asp><br /><br /> |
| 39 | <asp :Label ID="Label13a" runat="server" Text="Label"></asp><br /> |
| 40 | <asp :Label ID="Label13" runat="server" Text="Label"></asp><br /><br /> |
| 41 | <asp :Label ID="Label14a" runat="server" Text="Label"></asp><br /> |
| 42 | <asp :Label ID="Label14" runat="server" Text="Label"></asp><br /><br /> |
| 43 | <asp :Label ID="Label15a" runat="server" Text="Label"></asp><br /> |
| 44 | <asp :Label ID="Label15" runat="server" Text="Label"></asp><br /><br /> |
| 45 | </div> |
| 46 | </form> |
| 47 | </body> |
| 48 | </html> |
| 49 | |
| 50 |
Step 2: Click on Copy Code to Cut-n-paste code into String.aspx.vb
| Visual Basic | | copy code | | ? |
| 001 | |
| 002 | |
| 003 | |
| 004 | Partial Class LanguageBasics_String |
| 005 | Inherits System.Web.UI.Page |
| 006 | |
| 007 | Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
| 008 | |
| 009 | '**************************************************************************************** |
| 010 | ' Example #1: StartsWith(string) |
| 011 | ' Example #2: EndsWith(string) |
| 012 | ' Example #3: IndexOf(string[, startIndex][,count]) |
| 013 | ' Example #4: LastIndexOf(string[, startIndex][,count]) |
| 014 | ' Example #5: Insert(startIndex, string) |
| 015 | ' Example #6: PadLeft(totalWidth [, paddingCharacter]) |
| 016 | ' Example #7: PadRight(totalWidth [, paddingCharacter]) |
| 017 | ' Example #8: Remove(startIndex, count) |
| 018 | ' Example #9: Replace(oldString, newString) |
| 019 | ' Example #10: Substring(startIndex[, length]) |
| 020 | ' Example #11: ToLower |
| 021 | ' Example #12: ToUpper |
| 022 | ' Example #13: Trim |
| 023 | ' Example #14: Length |
| 024 | ' Example #15: Chars(index) |
| 025 | '**************************************************************************************** |
| 026 | |
| 027 | |
| 028 | '**************************************************************************************** |
| 029 | ' Example #1: StartsWith(string) |
| 030 | ' Returns a Boolean value that indicates if the string starts with the specified string. |
| 031 | '**************************************************************************************** |
| 032 | |
| 033 | Label1a.Text = "Example #1: StartsWith(string) " |
| 034 | |
| 035 | Dim strStartsWithExample As String = "This is a test string" |
| 036 | |
| 037 | Label1.Text = strStartsWithExample.StartsWith("This") 'Returns True |
| 038 | |
| 039 | |
| 040 | |
| 041 | '**************************************************************************************** |
| 042 | ' Example #2: EndsWith(string) |
| 043 | ' Returns a Boolean value that indicates if the string ends with the specified string. |
| 044 | '**************************************************************************************** |
| 045 | |
| 046 | Label2a.Text = "Example #2: EndsWith(string) " |
| 047 | |
| 048 | Dim strEndsWithExample As String = "This is a test string" |
| 049 | |
| 050 | Label2.Text = strEndsWithExample.EndsWith("string") 'Returns True |
| 051 | |
| 052 | |
| 053 | |
| 054 | '**************************************************************************************** |
| 055 | ' Example #3: IndexOf(string[, startIndex][,count]) |
| 056 | ' Returns an integer that represents the position of the first occurrence of the |
| 057 | ' specified number of characters. If you specify startIndex, that specifies |
| 058 | ' where to start looking. If you specify count, that specifies how many characters to |
| 059 | ' to search past start. If the string is not found, this method returns -1 |
| 060 | '**************************************************************************************** |
| 061 | |
| 062 | Label3a.Text = "Example #3: IndexOf(string[, startIndex][,count]) " |
| 063 | |
| 064 | Dim strIndexOfExample As String = "This is a test string" |
| 065 | |
| 066 | Label3.Text = strIndexOfExample.IndexOf("is") 'Returns 2 |
| 067 | |
| 068 | |
| 069 | |
| 070 | |
| 071 | '**************************************************************************************** |
| 072 | ' Example #4: LastIndexOf(string[, startIndex][,count]) |
| 073 | ' Returns an integer that represents the position of the last occurrence of the |
| 074 | ' specified number of characters. If you specify startIndex, that specifies |
| 075 | ' where to start looking. If you specify count, that specifies how many characters to |
| 076 | ' to search past start. If the string is not found, this method returns -1 |
| 077 | '**************************************************************************************** |
| 078 | |
| 079 | Label4a.Text = "Example #4: LastIndexOf(string[, startIndex][,count]) " |
| 080 | |
| 081 | Dim strLastIndexOfExample As String = "This is a test string" |
| 082 | |
| 083 | Label4.Text = strLastIndexOfExample.LastIndexOf("is") 'Returns 5 |
| 084 | |
| 085 | |
| 086 | |
| 087 | '**************************************************************************************** |
| 088 | ' Example #5: Insert(startIndex, string) |
| 089 | ' Returns a string with the specified string inserted beginning at the specified position. |
| 090 | '**************************************************************************************** |
| 091 | |
| 092 | Label5a.Text = "Example #5: Insert(startIndex, string) " |
| 093 | |
| 094 | Dim strInsertExample As String = "This is a test string" |
| 095 | Dim intIndex As Integer = 0 |
| 096 | |
| 097 | ' First find position of word test |
| 098 | intIndex = strInsertExample.IndexOf("test") |
| 099 | |
| 100 | ' Insert "simple" before "test" |
| 101 | Label5.Text = strInsertExample.Insert(intIndex, "simple ") |
| 102 | |
| 103 | |
| 104 | |
| 105 | '**************************************************************************************** |
| 106 | ' Example #6: PadLeft(totalWidth [, paddingCharacter]) |
| 107 | ' Returns a string that is right-aligned and padded on left with character specified. |
| 108 | ' If no padddingCharacter is specified, space is used. totalWidth is total width of column |
| 109 | ' This allows you to create a nice straight column even though lengths of text vary. |
| 110 | '**************************************************************************************** |
| 111 | |
| 112 | Label6a.Text = "Example #6: PadLeft(totalWidth [, paddingCharacter]) " |
| 113 | |
| 114 | Dim strPadLeftExampleA As String = "This is a test string" |
| 115 | |
| 116 | |
| 117 | |
| 118 | ' PadLeft "simple" before "test" |
| 119 | Label6.Text = strPadLeftExampleA.PadLeft(35) |
| 120 | |
| 121 | |
| 122 | |
| 123 | '**************************************************************************************** |
| 124 | ' Example #7: PadRight(totalWidth [, paddingCharacter]) |
| 125 | ' Returns a string that is left-aligned and padded on right with character specified. |
| 126 | ' If no padddingCharacter is specified, space is used. totalWidth is total width of column |
| 127 | ' This allows you to create a nice straight column even though lengths of text vary. |
| 128 | '**************************************************************************************** |
| 129 | |
| 130 | Label7a.Text = "Example #7: PadRight(totalWidth [, paddingCharacter]) " |
| 131 | |
| 132 | Dim strPadRightExampleA As String = "This is a test string" |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | ' PadRight "simple" before "test" |
| 138 | Label7.Text = strPadRightExampleA.PadRight(35) + "next column starts here" |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | '**************************************************************************************** |
| 145 | ' Example #8: Remove(startIndex, count) |
| 146 | ' Returns a string with the specified number of characters removed starting at startIndex. |
| 147 | ' If no Count is specified, the remainder of string is removed |
| 148 | '**************************************************************************************** |
| 149 | |
| 150 | Label8a.Text = "Example #8: Remove(startIndex, count) " |
| 151 | |
| 152 | Dim strRemoveExample As String = "This is a test string" |
| 153 | Dim intIndexRemove As Integer = 0 |
| 154 | |
| 155 | ' First find position of word test |
| 156 | intIndexRemove = strRemoveExample.IndexOf("test") |
| 157 | |
| 158 | ' Remove rest of string starting with word "test" |
| 159 | Label8.Text = strRemoveExample.Remove(intIndex) |
| 160 | |
| 161 | |
| 162 | |
| 163 | '**************************************************************************************** |
| 164 | ' Example #9: Replace(oldString, newString) |
| 165 | ' Returns a string with all occurences of oldString replaced by newString |
| 166 | '**************************************************************************************** |
| 167 | |
| 168 | Label9a.Text = "Example #9: Replace(oldString, newString) " |
| 169 | |
| 170 | Dim strReplaceExample As String = "This is a test string" |
| 171 | |
| 172 | ' Replace "This" with "That" |
| 173 | Label9.Text = strReplaceExample.Replace("This", "That") |
| 174 | |
| 175 | |
| 176 | |
| 177 | '**************************************************************************************** |
| 178 | ' Example #10: Substring(startIndex[, length]) |
| 179 | ' Returns the string that starts at the specified position and has the specified |
| 180 | ' length. If the length is not specified, all of the characters to the end are returned. |
| 181 | '**************************************************************************************** |
| 182 | |
| 183 | Label10a.Text = "Example #10: Substring(startIndex[, length]) " |
| 184 | |
| 185 | Dim strSubstringExample As String = "This is a test string" |
| 186 | Dim intIndexSubstring As Integer = 0 |
| 187 | |
| 188 | ' First find position of word test |
| 189 | intIndexSubstring = strRemoveExample.IndexOf("test") |
| 190 | |
| 191 | ' Get everything starting at "test" to end of string |
| 192 | Label10.Text = strSubstringExample.Substring(intIndexSubstring) |
| 193 | |
| 194 | |
| 195 | |
| 196 | '**************************************************************************************** |
| 197 | ' Example #11: ToLower |
| 198 | ' Returns the string in Lowercase |
| 199 | '**************************************************************************************** |
| 200 | |
| 201 | Label11a.Text = "Example #11: ToLower" |
| 202 | |
| 203 | Dim strToLowerExample As String = "This is a test string" |
| 204 | |
| 205 | ' Return Lowercase |
| 206 | Label11.Text = strToLowerExample.ToLower |
| 207 | |
| 208 | |
| 209 | '**************************************************************************************** |
| 210 | ' Example #12: ToUpper |
| 211 | ' Returns the string in Uppercase |
| 212 | '**************************************************************************************** |
| 213 | |
| 214 | Label12a.Text = "Example #12: ToUpper " |
| 215 | |
| 216 | Dim strToUpperExample As String = "This is a test string" |
| 217 | |
| 218 | ' Return Uppercase |
| 219 | Label12.Text = strToUpperExample.ToUpper |
| 220 | |
| 221 | |
| 222 | |
| 223 | '**************************************************************************************** |
| 224 | ' Example #13: Trim |
| 225 | ' Returns the string with leading and trailing spaces removed |
| 226 | '**************************************************************************************** |
| 227 | |
| 228 | Label13a.Text = "Example #13: Trim " |
| 229 | |
| 230 | Dim strTrimExample As String = " ABC " |
| 231 | |
| 232 | ' Return Uppercase |
| 233 | Label13.Text = strTrimExample.Trim.Length |
| 234 | |
| 235 | |
| 236 | '**************************************************************************************** |
| 237 | ' Example #14: Length |
| 238 | ' Returns the string with leading and trailing spaces removed |
| 239 | '**************************************************************************************** |
| 240 | |
| 241 | Label14a.Text = "Example #14: Length " |
| 242 | |
| 243 | Dim strLengthExample As String = " ABC " |
| 244 | |
| 245 | ' Return Uppercase |
| 246 | Label14.Text = strLengthExample.Length |
| 247 | |
| 248 | '**************************************************************************************** |
| 249 | ' Example #15: Chars(index) |
| 250 | ' Gets the character at the specified index |
| 251 | '**************************************************************************************** |
| 252 | |
| 253 | Label15a.Text = "Example #15: Chars(index) " |
| 254 | |
| 255 | Dim strCharsExample As String = "ABC" |
| 256 | |
| 257 | ' Return Uppercase |
| 258 | Label15.Text = strCharsExample.Chars(1) |
| 259 | |
| 260 | |
| 261 | |
| 262 | End Sub |
| 263 | End Class |
| 264 | |
| 265 | |
| 266 |
Step 3: Click on Copy Code to Cut-n-paste code into web.config right after the appSettings section
| XML | | copy code | | ? |
| 1 | |
| 2 | <connectionstrings> |
| 3 | <add name="Northwind_ConnectionString" |
| 4 | connectionString="Server=(local)\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI" /> |
| 5 | <add name="Pubs_ConnectionString" |
| 6 | connectionString="Server=(local)\SQLEXPRESS;Initial Catalog=pubs;Integrated Security=SSPI" /> |
| 7 | </connectionstrings> |
| 8 |
Related posts:
- C# ASP.NET String Examples – String Examples ASP.NET C# C# ASP.NET String Examples - String Examples ASP.NET C#...
- C# String Examples – String Examples C# C# String Examples - String Examples C#...
- VB.NET String – String VB.NET VB.NET String - String VB.NET ...
- VB.NET ASP.NET StringBuilder Source Code Example VB.NET ASP.NET StringBuilder Source Code Example...
- C# ASP.NET StringBuilder Source Code Example C# ASP.NET StringBuilder Source Code Example...
Related posts brought to you by Yet Another Related Posts Plugin.
