473,320 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,320 developers and data experts.

VB.NET Snippets - String

sashi
1,754 Expert 1GB
'//--- Reverse String ---//
Expand|Select|Wrap|Line Numbers
  1.       Module RevString
  2.  
  3.       Sub Main()
  4.         Dim inputString As String = Console.ReadLine()
  5.         ReverseOrder(inputString)
  6.       End Sub
  7.  
  8.       Private Sub ReverseOrder(ByVal textInput As String)
  9.         Dim text2Rev As String = textInput
  10.         Dim reversed As String
  11.  
  12.         Dim charArray() As Char = textInput.ToCharArray()
  13.         Array.Reverse(charArray)
  14.         reversed = charArray
  15.  
  16.         Console.WriteLine("")
  17.         Console.WriteLine("Original Text: " + text2Rev)
  18.         Console.WriteLine("Reversed Text: " + reversed)
  19.       End Sub
  20.  
  21.       End Module
  22.  
'//--- Generate random numbers ---//
Expand|Select|Wrap|Line Numbers
  1.       Public Function GenerateRandomString() As String
  2.         GenerateRandomString= System.Guid.NewGuid.ToString
  3.       End Function
  4.  
'//--- Format phone numbers ---//
Expand|Select|Wrap|Line Numbers
  1.       Dim pn As String = "(444) 444-444"
  2.       Dim newPn As String = Replace(Replace(Replace(pn, "-", ""), "(", ""), ")", "")
  3.       newPn = String.Format("{0:###-###-####}", Convert.ToInt64(newPn))
  4.  
'//--- Email address validator ---//
Expand|Select|Wrap|Line Numbers
  1.  
  2.       Private Function IsValidEmailFormat(ByVal s As String) As Boolean
  3.         Dim result As Boolean = False
  4.  
  5.         If Not String.IsNullOrEmpty(s) Then 
  6.           '^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$
  7.  
  8.            Dim pattern As String = My.Settings.Email_Validation_Pattern
  9.  
  10.            Dim match As RegularExpressions.Match =  RegularExpressions.Regex.Match(s, pattern)
  11.            result = match.Success
  12.  
  13.          End If
  14.  
  15.       Return result
  16.       End Function
  17.  
Feb 14 '10 #1
1 13251
erikbower65
12 Byte
Thanks for sharing the code, its very useful information. Try the tool if you want to code analysis.
Jul 18 '23 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: asmirnov1234567890 | last post by:
Hi I'd like to place this code to C++ code snippets site. Does anyone know about where is could be? Andrei Smirnov ======================================= // // example of how to strip...
1
by: Sanjay Pais | last post by:
Any one played around with snippets should be able to help me :) I need to Add a custom code Snippet and need the value of the variable ProcedureName to be set to the name of the class. I know I...
2
by: - Steve - | last post by:
I'm working on my asp.net site and I'm wondering what the best way to reuse little snippets of code is? Right now I have a Class in it's own cs file that I call Snippets. Then when I want to...
2
by: Steve Franks | last post by:
I'm using VS.NET 2005 beta 2 and am excited about the idea of using code snippets. This is a nice time saver. For example I need to read all text from a file, and see that with a simple command...
5
by: moondaddy | last post by:
I've seen how people have snippets of code stored over by the tool box and then can drag them into a code page. What do you call this and what's a reference on how to do this? Thanks. --...
0
by: Ofer B. | last post by:
Hi Do any one know where visual studio save it's data about the code snippets directories? I added some directories with snippets and than remove them with the "Code Snippets Manager". now,...
0
by: Robert Zurer | last post by:
Hello I have posted this here once before to no avail so I thought I might try again I love the snippets feature and use it constantly. However when I recently downloaded and ran the C#...
13
by: frk.won | last post by:
I am interested in learning how to use the VS 2005 code snippets. However, I wish to know what are the best ways to source control the code snippets? Are there any source safe/subversion...
2
by: Zytan | last post by:
You can download them here: http://msdn2.microsoft.com/en-us/vstudio/aa718338.aspx This snippet seems wrong: Visual C# 2005 Code Snippets -filesystem -Search a Directory for Files Recursively ...
2
by: Wikicodia Admin | last post by:
Dears, Wikicodia is a wiki based project for sharing code snippets. We're collecting large number of code snippets for all code-based programming languages, scripts, shells and consoles. We wish...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.