.NET Framework - simple UCase program??

Asked By Jason
30-Mar-08 05:04 PM
Can someoen show me a simple way to do this?

I want to either read a file or copy and paste text into an Rich text
textbox on the form.  I then want to hit a button and the program will
run through the code and in a label display all of the CAPITAL letters
in that document.

so if I had this document.

i think That Some of The People here do great things.

it would show me:
TSTP

is there a show ucase stament or something,  thanks for any help
StringBuilder
(1)
ToCharArray
(1)
LINQ
(1)
ToArray
(1)
IsLower
(1)
IsUpper
(1)
Concat
(1)
RegEx
(1)
  Nathan Sokalski replied...
29-Mar-08 08:14 PM
No, there is not a built-in function to do that, but you may be interested
in the following functions:

Char.IsUpper()
Char.IsLower()

If you use the ToCharArray() method of the String class to get an array of
Chars, you can then use a loop to check each one, sort of like this:

Dim original As String
Dim capitals As String = ""
Dim originalchars() As Char = original.ToCharArray()
For Each x As Char In originalchars
If Char.IsUpper(x) Then capitals = String.Concat(capitals, x)
Next

You will need to assign your original string a value in the declaration (or
sometime before calling the ToCharArray() method). Depending on the length
of your original string, you may want to use the System.Text.StringBuilder
class for the capitals variable for the sake of efficiency, but that is your
decision. Hopefully this helps.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
  Spam Catcher replied...
30-Mar-08 01:22 AM
4ef8ddda4d7b@l42g2000hsc.googlegroups.com:


You can either use Regular Expressions or String Parsing to do this.

A simple RegEx to find uppercase characters would be [A-Z]. Then you can
loop through all the matches and display it to the user.

--
spamhoneypot@rogers.com (Do not e-mail)
  Bill McCarthy replied...
30-Mar-08 01:33 AM
Or you can use LINQ syntax in VB9 (2008) to make this :

Dim capitals As String = (From c In original Where Char.IsUpper(c)).ToArray
Create New Account
help
Is Linq to SQL any good? .NET Framework I am a big fan of linq but in my opinion linq to sql is a complete waste of time. Why on earth take something that is difficult to write by creating a translation layer. I see people here struggling to write linq to sql queries. It also creates the problem of being locked into a particular product 1) Entity Framework (1) Visual Studio (1) Silverlight (1) Oracle (1) If we ignore the LINQ to SQL vs LINQ to EF aspect. You should use LINQ to EF not LINQ to SQL. .NET wanted an ORM. Many people including me like ORM's for certain
Linq-to-Sql var null question or observation .NET Framework This is more an observation than MyMatchingTables = null, but rather I get zero hits (or .Count = 0). Must be built into Linq-to-Sql. I have been using it for years but this is the first time AField.StartsWith(aString) select X; / / why is var MyMatchingTables never null? Must be built into Linq to Sql to never return null? myMyTableList = MyMatchingTables.ToList(); } catch (Exception ex) { Debug.WriteLine(ex the point So this could return a var MyMatchingTables = 3D null? But I thought in Linq-to-Sql that is not allowed? So it will throw an exception (in the try a row out of the table encapsulated as an object / entity, as that is what Linq does. What is Language Integrated Query? LINQ is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages. Microsoft LINQ defines a set of query operators that can be used to query, project and filter to the object domain * ** ** ** *). Queries written using the query operators are executed either by the LINQ query processing engine or, via an extension mechanism, handed over to LINQ providers which either
StringBuilder much much faster and better than String for concatenation !!! .NET Framework StringBuilder better and faster than string for adding many strings. Look at the below. It's amazing how much faster StringBuilder is than string. The last loop below is telling: for adding 200000 strings of 8 char each, string took over 25 minutes while StringBuilder took 40 milliseconds! Can anybody explain such a radical difference? The hardware running this program was a Pentium IV with 2 GB RAM. RL / / stringbuilder much faster than string in concatenation / / / / / / / / / / / / / / using System; using System.Collections.Generic; using System Linq; using System.Text; namespace console1 { class Program { static void Main(string[] args) { Console.WriteLine("hi are: {0}, {1}", myUpdateTime.txtConcatTime, myUpdateTime.txtStringBTime); } } } / * * OUTPUT * results: * for 1000 iterations: string = 10.01ms; stringbuilder = 0 * for 5000 iterations: string = 410.6ms; stringbuilder = 0 * for 50k iterations: sring = 79013 ms; stringbuilder = 0; * for 10k iterations : string = 1772.5
pointer + = mfTransactionType 'etc etc There appears no native VB.Net equivalent to this method. The StringBuilder Class does not have this method either. It should be noted that the Replace method for either String or StringBuilder would not be appropriate for the above. The above algorithm that I use will actually Thanks for your time. VB.NET Discussions ASCIIEncoding (1) System.Runtime.CompilerServices (1) System.Text.StringBuilder (1) MyFields.mfTransactionType (1) MyFields.mfRecordType (1) FieldPos.FullSize (1) RichTextBox (1) QueryPerformanceCounter (1) Oops True" and "False" in the boxes. So, you will have to stick either with the StringBuilder or the & operator for concatenation. If I understood correctly, you have to build a new content of a previous one, right? To make this considerably faster, you can use one Stringbuilder object with maximum capacity (120 in this case), and set it is Length property to probably much slower. Instead something like: Module whatever Sub AddWithPadding(ByVal sb As System.Text.StringBuilder, _ ByVal Text As String, ByVal TotalLength As Integer) sb.Append(Text) sb.Append(New the time with a little test: Shared Sub test() Dim sb As New System.Text.StringBuilder(10) Dim watch = Stopwatch.StartNew For i = 1 To 30000000 sb.Length = 0 sb.AddWithPadding it as you say returns a new string. It basically does some checks, uses a StringBuilder to build the new string, and then set your string reference to the StringBuilder instances
about the string Class and the StringBuilder class .NET Framework Hello! I read in a book and here is a question and the answer that I'm not satisfied with. When should you use the StringBuilder class instead of the String class. 1.When building a string from shorter strings. 2 3 because string object is immutable so here is it an advantage to use the StringBuilder class but according to the book is the right answer 1. But if you build a string from shorter strings you don't have to use a StringBuilder class as string s = "This" + "is" + "a" + "Test"; I can accept numer 1 if they how the book can say that the right answer is number 1 / / Tony C# Discussions StringBuilder (1) GC (1) Strings (1) Replace (1) On Sep 22, 12:25 = A0pm, "Tony Johansson" <johansson.anders. . .@telia.com> ble The book must have been referring to concatentation. StringBuilder will be more efficient in that scenario because it uses techniques that require fewer copy See http: / / pobox.com / ~skeet / csharp / str = ingbuilder.html for more information. . table ng is stringbuilder.html Oh, by the way, I should point out that you're example is unique will occur at compile time since the individual strings are constant. In that respect the StringBuilder would not perform any better. On Sep 22, 1:25 pm, "Tony Johansson" <johansson.anders