Monday 15 July 2013

vb.net - tOGGLE cASE For Textbox? -



vb.net - tOGGLE cASE For Textbox? -

how can add together toggle case textboxes, example, click button , changes text in textbox toggle case (hello -> hello), takes first letter , lower cases , rest upper cases it.

here method using .net civilization functions first convert title case , invert case "toggle case"

private sub btn_converttotogglecase_click(sender object, e eventargs) handles btn_converttotogglecase.click 'get current value of textbox dim mytext string = mytextbox.text 'convert title case using built in .net tools dim mytextinfo system.globalization.textinfo = new system.globalization.cultureinfo("en-us", false).textinfo mytext = mytextinfo.totitlecase(mytext) 'then invert case of characters dim invertedtext char() = mytext.select(function(c) if(char.isletter(c), if(char.isupper(c), char.tolower(c), char.toupper(c)), c)).toarray() 'finally convert string mytextbox.text = new string(invertedtext) end sub

vb.net

No comments:

Post a Comment