Code-Projects - Making Coding Easier: Multipal Repalce Text Data in TextBox - Code-Projects - Making Coding Easier

Jump to content

Hide message Show message
Welcome to Code-Projects - Making Coding Easier!

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger and more.

Welcome to Code-Projects - Making Coding Easier

Welcome to Code-Projects - Making Coding Easier, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information. Take advantage of it immediately, Register Now or Sign In.

  • Start new topics and reply to others
  • Subscribe to topics and forums to get automatic updates
  • Add events to our community calendar
  • Get your own profile and make new friends
  • Customize your experience here
Guest Message by DevFuse
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Multipal Repalce Text Data in TextBox
Rate Topic: -----


#1 User is offline   mepalival 

  • 1-Bit Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 18-December 09

Posted 27 January 2010 - 07:09 AM

I M using small application
it has two textbox
i m put data in textbox1 and find output in textbox2
i want to do mulipal replace text in textbox2
like

Quote

"KB" to "kilobyte"
"MB" to "megabyte"
"GB" to "gigabyte"
"TB" to "terabyte"


For this i m using this Code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox2.Text = TextBox1.Text

        Dim i As Integer = 0
        Do While i < 1000
            i = i + 1
            If InStr(TextBox2.Text, "kb") Then
                TextBox2.Text = Replace(TextBox2.Text, "kb", "kilobyte")
            ElseIf InStr(TextBox2.Text, "mb") Then
                TextBox2.Text = Replace(TextBox2.Text, "mb", "megabyte")
            ElseIf InStr(TextBox2.Text, "gb") Then
                TextBox2.Text = Replace(TextBox2.Text, "gb", "gigabyte")
            ElseIf InStr(TextBox2.Text, "tb") Then
                TextBox2.Text = Replace(TextBox2.Text, "tb", "terabyte")
 
           End If
        Loop

    End Sub


Is there any other way to make it easier !!
0


#2 User is offline   Cairns 

  • 1-Bit Member
  • Pip
  • Group: Members
  • Posts: 16
  • Joined: 02-March 09

Posted 06 March 2010 - 05:16 AM

Yes, there is.

First of all there is no need for a loop, lol.
Second of all you don't need to use If Instr because the Replace function doesn't occur error's.

I have fixed your code and you can copy/paste it from below:

TextBox2.Text = Replace(TextBox2.Text, "kb", "kilobyte")
TextBox2.Text = Replace(TextBox2.Text, "mb", "megabyte")
TextBox2.Text = Replace(TextBox2.Text, "gb", "gigabyte")
TextBox2.Text = Replace(TextBox2.Text, "tb", "terabyte")

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users





Downloads Free RapidShare Downloads RapidShare Free Download LinksDirect DownloadFull Downloads

Masti Mamu GillWarez FeeltheFlow OnlineKeyStore Your Site Here
Your Site Here Your Site Here Your Site Here Your Site Here Your Site Here

Enter your sign in name and password


Sign in options
Log in with Facebook   Or sign in with these services