Read Upper And Lower Case Letters Without Having To Put The Upper Case Letters In Select Case Statement
Oct 28, 2009
i have a program using a select case to convert letters to special charaters. My question is how can I get the code to read upper and lower case letters without having to put the upper case letters in my select case statement. Example: Part of my code is
I'm new to VB and I'm trying to get this app to recognize that a "C" is the same as "c" but for some reason its not recognizing it. Its seeing the lower case letters as 10%.
Here is the code I currently have... Private Sub btnCalculate_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnCalculate.Click Dim subtotal As Decimal = CDec(txtSubtotal.Text) Dim discountPercent As Decimal [Code] .....
Here is what ive got: a1 = inputbox("YES or NO") If a1 = "YES" Or a1 = "yes" Then
That's all we need to know. There are a variety of choices people could put in the input box: YES YEs YeS yES yes Yes yEs yeS I don't want to do if a1 = "YES" or a1 = "YEs" or ... etc
Is there some way I can do: if a1 = allcase."YES" then Or something along the lines of that?
I'm currently using this bit of code to let only Y, N, and Backspace be typed in my textbox: [code] My problem is that when I debug, the "n" has to be capitalized in order for it to show up in my textbox and the "y" has to be lower cased. Is there anyway that I can bypass this to where it doesn't matter wether or not it is upper or lower case?
I am trying to change a user inputed sentence in a console application to the following specs. only the first letter caplized and put a peroid at the end.So have I have the user enter a sentence as a string changed the string to all lower case and displayed the string with a peroid at the end I just can't figure out how to change the first letter of the string to upper case
When my form loads it adds some handles (using AddHandler) to a sub (showStatus). What this sub does is checks which control activated the sub (using sender.Equals) and displays text in the status label (status) accordingly.For this I use an If...Then statement for each possibility. There are many possibilities and my code get cluttered. Is there a way to do the same thing with a Select...Case statement. I tried: Select Case sender Case tbOne : status.Text = "blahblahblahblahblahblah" End Selectwhere: tbOne is a textbox, status is a StatusLabelIt gives me an error though, saying "Operator '=' is not defined for types 'Object' and 'System.Windows.Forms.TextBox'."Any ideas on how I can get this to work with a select case statement?
I have a series of text fields on a simple form (inside a group box) I would like to enforce all the text be upper case upon submission to the database. I know I can use the Ucase command. The question is implementation. How can I very efficiently force all the field values to upper case vs. say doing Ucase(TextBox1), Ucase(TextBox2).... ( I have 12 fields in this case) Is there a way to treat the text boxes as a collection and do it in one shot? Just trying to be very efficient and create clean, tight code even on such a simple thing.
I am storing some user settings by the very handy My.Settings classes in VB.net and it seems to be taking a mixed case string (a file path and filename) and returns it in all upper case.
Public Function TitleCase(ByVal strIn As String) Dim result As String = "" Dim culture As New CultureInfo("en", False) Dim tInfo As TextInfo = culture.TextInfo() result = tInfo.ToTitleCase(strIn) Return result End Function If I input "TEST" into the function above. The output is "TEST". Ideally it would output "Test". I also tried the code snippets from this post to no avail: Use of ToTitleCase.
Both of the below return the computers name in upper case even when the actual name is in lower case: MsgBox("Computer name: " & My.Computer.Name) MsgBox(Environment.MachineName) Is this true for every windows version? I only use MsgBox when testing.
I have a ton of questions that I cant seem to figure out in regards to VB Script.
1. How do you convert text in a text box to Upper Case? 2. How do you write the code to display messages in a Label box? 3. How do you check for numeric values? 4. How do you check for an empty string and find the length? 5. How do you extract a substring?
Firstly Case 2 runs. Throws exception. And right after this debugger shows that next processed statement is Case Else. Only after Case Else throws own exception Catch block start working. I've never seen this trick. Why can this happened?I'm sure the block is entered once (not like this:first enter hit Case 2 and second hit Case Else).
Update:-To Matt Wilko. Thank you for answering. I've switch to Strict On in Options of VS2010 but nothing has changed. Command is variable, not function. Watch tool shows that on each step Command is the same ( Command = 2).
Fixed. Yeeaaaahhh. I simplefy code to Try Select Case 2 Case 2
[code]....
and change project to Console app. This works as I mention. The fix was in Release mode. I was debugging in Release mode. When I switch to Debug mode everything goes as it should.
I just replaced a different segment of code with the select case statement and it works fine. However I don't understand what the dim is for after you do "Select case [variable name here]"
I currently just dimmed a value as nothing. I didn't specify any data type for my variable I'm using for this case statement. But it works.[code]...
I've got the following that has got multiple values of a particular variable and I don't want to stack up to a lot of IF ELSE statements to handle them, so I'd be grateful if some one could very kindly modify the code by using the SELECT CASE statement. Also, I'd like dgMarksEntry.Item(7, i).Value and dgMarksEntry.Item(8, i).Value to handle RANK and COUNT the number of items entered respectively. [Code]
I am not really a fan of if statements. I think they should only be used when comparing different values like this:
Dim status as boolean = false Dim number as integer = 5 if status.equals(true) then
[Code]....
or msgbox on a different line whatever you want.... What is this rule about that select case should only be used if there more then 2-3 options. Is it wrong to use a select case instead?
in combo box string is xxx and yyy and zzz.we have to store the value to each string like xxx=10, yyy=20 and zzz=30. formula is string(xxx)/1.71^(1/2).. if we select xxx formula have to take value 10 or yyy means formula have to take value 20.