• home
  • forum
  • my
  • kt
  • download
  • How to change the case of a string

    Author: 2008-09-13 09:05:15 From:

    Firstly, to start off, open up Visual Basic 6.0.

    When you've done that, it should prompt you with a dialog box asking you what type of project you want to make. Choose Standard EXE and press open.

    First Step.

    Once you have done that, you should have something that looks like this:

    Step 2.

    Now we are going to set up the design of the application. To do this we are going to need two command buttons and one textbox.

    So go over to your toolbox (the thing that says "General" and has lots of little icons), and select the command button (the one circled in red in the picture below) and create two of them on the form. Then select the textbox (the ne circled in green) and create one of them on the form.

    Step 3

    Step4.2

    Once that is done, we need to change the names of the objects and the text that they say.

    So click on the first command button (Command1) and go over to the right hand side where you should see something like this:

    Step 5

    Now go to the caption area (the one that is highlighted on the picture) and double click "command1" and change it to "Uppercase." Now go up to the bit that says Name (it should be the very first one) and change that to "cmd_uppercase" which is the proper way to name a command button. When this is done, do the same thing for the other command button, except the caption should be "Lowercase" andthe name, "cmd_lowercase."

    Step 6

    Now we need to do the same for the textbox. But this time, instead of Caption, there is something different. This is Text. The text property is what you want the text to be displayed as. You can change this in the code aswell as when you run your application (unless you have it locked). So change the text to whatever you want. Now change the Name property to "txt_changed" or something similar.

    Step 7

    Now for the coding!

    Double click on the command button that says "Uppercase." It should take you to a blank screen that says:

    Private Sub cmd_uppercase_Click()

    End Sub

    In the middle of this, insert this code

    txt_changed.Text = UCase(txt_changed.Text)

    You should now have this code

    Private Sub cmd_uppercase_Click()
    txt_changed.Text = UCase(txt_changed.Text)
    End Sub

    What this is telling the application to do is, when you press the command button for uppercase it is getting the text for it then making the text exactly the same, but changing it to uppercase.

    The next peice of code is the code for the Lowercase button. You should be able to figure this one out yourself. If you can't then here is the code:

    Private Sub cmd_uppercase_Click()
    txt_changed.Text = LCase(txt_changed.Text)
    End Sub

    This is telling the application to do the exact same thing as the Uppercase button except telling it to make it lowercase.

    Now press F5. This will run your application. Alternitivly you can press this button (the one highlighted in blue):

    You should be able too, now, when your application is running, be able to press one button and it converts the text to UPPERCASE and press another button and it converts it to lowercase,

    When you are done with your application, exit out of it and save.

     

    Download Project

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      .NET (8)
      Buttons (3)
      Database Related (7)
      Date and Time (1)
      Development (3)
      Error Handling (2)
      File Manipulation (5)
      Introduction to Visual Basic (13)
      Miscellaneous (3)
      Multimedia (10)
      Networking (10)
      Security (1)
      VB Script (6)

    New

    Hot