Error in my application DomainUpDown and Integer

Conejo

Well-known member
Joined
Jul 24, 2013
Messages
65
Location
USA
Programming Experience
1-3
unhandled exception has ocurred... cannot convert start value type "integer" limit value of type domainupdown and step value of type integer to a common numeric,
how do i fix this help is apreciated thanks.
my program helps the user create passwords here is the code which isnt wokring:
Public Function Password() As Object
        Dim intRnd As Object
        Dim strName As Object
        Dim intNameLength As Object
        Dim intLenght As Object
        Dim strInputString As Object
        Dim inStep As Object

        strInputString = character.Text
        intLenght = Len(strInputString)
        intNameLength = DomainUpDown1 '<<<<<<THIS IS THE PROBLEM
        Randomize()
        strName = ""

        For inStep = 1 To intNameLength
            intRnd = Int((intLenght * Rnd()) + 1)
            strName = strName & Mid(strInputString, intRnd, 1)
        Next

        Password = strName
    End Function
 
Last edited by a moderator:
Firstly, I've cleaned up your code to make it more readable. Please do so for us in future.

As for the issue, the cause should be fairly obvious. You have an Integer variable and you're trying to assign a DomainUpDown to it. Is a DomainUpDown and Integer? Obviously not, so it can't be assigned where an Integer is expected. Presumably what you actually want is some aspect of the DomainUpDown rather than the DomainUpDown itself. For instance, if I had a spot on a form to write down the colour of my car, I'm going to put my actual car on the form, am I? So, what is it that you actually want from the DomainUpDown?
 
i fixed it here is how

Public Function Password() As Object
Dim intRnd As Object
Dim strName As Object
Dim intNameLength As Object
Dim intLenght As Object
Dim strInputString As Object
Dim inStep As Object
dim length as integer
length = domainupdown1.text

strInputString = character.Text
intLenght = Len(strInputString)
intNameLength = (length)
Randomize()
strName = ""

For inStep = 1 To intNameLength
intRnd = Int((intLenght * Rnd()) + 1)
strName = strName & Mid(strInputString, intRnd, 1)
Next

Password = strName
End Function

thanks btw
 
Back
Top