Results 1 to 2 of 2

Thread: error in code

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    4

    error in code

    I'm working on a program and withen it i need to take a value from a textbox in one form to text box in another form

    i wrote this code to do this

    Code:
    Public Class Form4
        Dim generator As New Random
    
            MaskedTextBox1.Text = generator.Next(Form3.MaskedTextBox1.Text)
            MaskedTextBox2.Text = generator.Next(1111111, 9999999)
    i have two text box in form4

    in the first one i need to take a value from3 randomally

    in the second one i need to generate a random data ..


    when i run the code i face a probem, the program tes me that there is an error;

    Conversion from string " -" to type 'Integer' is not valid.


    Can anybody plz tell me what's wrong ??

    I linked the program with my database (access) by new source data

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: error in code

    Random.Next Takes an Integer as Input. Check your Maskedinput Text. It may contain - symbol in the Text. You could like removing the - from the Text as

    Code:
    generator.Next(Form3.MaskedTextBox1.Text.Remove("-",""))
    is the One Option
    Please mark you thread resolved using the Thread Tools as shown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width