Writing short method for my textbox


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Writing short method for my textbox

  1. #1
    Join Date
    Apr 2008
    Posts
    4

    Writing short method for my textbox

    Hi guys

    I have a problem with method. I have trackbar with maximum value number up to 10000. When I write the value numbers from 0 to 999 on the textbox, the trackbar value moved as it works ok so far. On 1.0 where I want the trackbar value must be target on 1000, if I go over the limit like 1.1, I want the warning message pop up. But on mine I have to write the longest code from 1.0 (the trackbar maximum target 1000) to 100.0 (trackbar maximum target 2000). I don't want to write that crazy numbers to make my form slowing down.



    Here it the code:
    Code:
         If Form2.Textbox.Text = 1.1 Then
                    Form2.TrackBar2.Value = 1000
                    Textbox.ShowDialog()
                End If
            End If
    
    
                If Form2.Textbox.Text = 1.2 Then
                    Form2.TrackBar2.Value = 1000
                    Textbox.ShowDialog()
                End If
            End If
    
    
                If Form2.Textbox.Text = 1.3 Then
                    Form2.TrackBar2.Value = 1000
                    Textbox.ShowDialog()
                End If
            End If
    
                If Form2.Textbox.Text = 1.4 Then
                    Form2.TrackBar2.Value = 1000
                    Textbox.ShowDialog()
                End If
            End If
    
    
                If Form2.Textbox.Text = 1.5 Then
                    Form2.TrackBar2.Value = 1000
                    Textbox.ShowDialog()
                End If
            End If
    
    
                If Form2.Textbox.Text = 1.6 Then
                    Form2.TrackBar2.Value = 1000
                    Textbox.ShowDialog()
                End If
            End If
    
                If Form2.Textbox.Text = 1.7 Then
                    Form2.TrackBar2.Value = 1000
                    Textbox.ShowDialog()
                End If
            End If
    
                If Form2.Textbox.Text = 1.8 Then
                    Form2.TrackBar2.Value = 1000
                    Textbox.ShowDialog()
                End If
            End If
    
                If Form2.Textbox.Text = 1.9 Then
                    Form2.TrackBar2.Value = 1000
                    Textbox.ShowDialog()
                End If
            End If
    
    
                If Form2.Textbox.Text = 2.0 Then
                    Form2.TrackBar2.Value = 1000
                    Textbox.ShowDialog()
                End If
            End If
    
    ETC.....

    What is the short way of writing the code in proper way??



    Thanks,
    Mark
    Last edited by mark103; 05-02-2008 at 06:55 PM.

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    How about
    Code:
    If Form2.Textbox.Text => 1.1 And Form2.Textbox.Text <= 1.5 Then
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Replies: 0
    Last Post: 09-08-2003, 01:23 AM
  2. textbox doesn't detect change in itself
    By sander in forum ASP.NET
    Replies: 2
    Last Post: 02-27-2002, 02:08 AM
  3. Replies: 3
    Last Post: 04-13-2001, 09:13 PM
  4. Quick fix...plz help
    By Brad Overlund in forum Web
    Replies: 4
    Last Post: 11-15-2000, 12:51 PM
  5. Replies: 0
    Last Post: 11-02-2000, 08:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center