Report Designer: Proper Case and Trimmed fields
Greetings, All,
I have the following calculated field in Report Designer that concatenates all applicable fields for a street address:
(STREETNO.ToString().Trim() != "" ? STREETNO + " " : "") + (PREDIRECTION.ToString().Trim() != "" ? PREDIRECTION + " " : "") + (STREETNAME.ToString().Trim() != "" ? STREETNAME + " " : "") + (STREETTYPE.ToString().Trim() != "" ? STREETTYPE : "")
How can I get my STREETNAME and STREETTYPE fields into ProperCase (first letter of every word Uppercase) -- they are the only fields in my entire property report that are in UPPERCASE, all my other data is in ProperCase and it just bugs me. I'm fine with an addition to my field calculation above.
ALSO, while I'm at it, how can I trim my ZIPCODE field to just show the first 5 digits??????
I'd love to do a Report Dataset Transform workflow for al this, but I think that's waaaaay over my head.
Thanks!
Lisa
0
-
There are a few ways to do title case, the shortest in VB is probably with the StrConv builtin function (https://support.microsoft.com/en-us/help/312897/how-to-convert-string-to-lowercase-uppercase-or-title-proper-case-by-u) . StrConv(string, VbStrConv.ProperCase)What you probably want for your zips is the .Substring method (https://stackoverflow.com/questions/10148718/slicing-string-in-visual-basic) .ZIP.Substring(0,5)0 -
Hey Zack,
Thanks so much for your time!
So the substring of my ZIPCODE went great!
I'm not having as much luck with the ProperCase for my STREETNAME field, tho.
I have tried the following options:
StrConv(STREETNAME, VbStrConv.ProperCase) = returns street name, all uppercase (no change)
Console.WriteLine(StrConv(STREETNAME, VbStrConv.ProperCase)) = returns error: Control Script failed for control TextBox1 , Source=calc_STREETNAME
Console.WriteLine(textInfo.ToTitleCase(STREETNAME) = retunrs error: Control Script failed for control TextBox1 , Source=calc_STREETNAME
Where am I going wrong?0 -
Are you trying to access the console while running a report? You're gonna have a bad time!
I haven't looked too closely at the documentation, but I do notice that all of their pre-proper text is in lower case, perhaps you would try squeezing a .ToLower method in there before converting to proper case.
I also found that the answer on the Stack post "How to camel case words that are uppercased" (https://stackoverflow.com/questions/5820488/vb-net-how-to-camel-case-words-that-are-uppercased) using the cultureinfo namespace also does this.
0 -
You're a GENIOUS, Zack! This Works:
System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(STREETNAME.ToLower())
Many thanks! I owe you a fruit basket!
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
4 Kommentare