1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Substring splitting

Discussion in 'Visual Basic .NET' started by roach, May 27, 2013.

  1. roach

    roach BANNED BANNED

    Joined:
    Sep 8, 2009
    Messages:
    740
    Likes Received:
    395
    Hello my fellow blackhatters. I have a quick question that hopefully a fellow coder can help me with. I am using a dictonary and a first name last name file to generate random usernames and passwords that look real. I do understand I could just generate random letters and numbers, but the site I am botting has a smart owner and he auto banns accounts if the screen name is something like "fsd87fdhkja7". Ok with that said. The files i am using generate perfect usernames using this function:

    Code:
         Dim names = My.Resources.names.Split(Environment.NewLine)                
                    Dim rnd As New Random()
                    Dim name = names(rnd.Next(0, names.Length))
                    name = name.Replace(ControlChars.Lf, "")
                    Dim dictwrds = My.Resources.dict.Split(Environment.NewLine)
                    Dim dictwrd = dictwrds(rnd.Next(0, dictwrds.Length))
                    dictwrd = dictwrd.Replace(ControlChars.Lf, "")
                    name = name & dictwrd
                    name = name.Replace(" ", "")

    The problem I have is that there is a max limit on the length of the usernames for this site. I already know that you can tell the length of a string using:

    Code:
    string.length
    So i am perfectly able to tell if I am over or under the limit for the username. What I need is a function to trim the string to not be over the amount of allowed letters and numbers. I understand I could just have it regenerate the username if it is over the max, but that is not good enough for me. Can any coder shed some light on this for me? I just want my function to trim a few letters or numbers off the end if the username string is over the max allowed. Thanks in advance.

    This is my starting point for this:

    Code:
     if name.length > maxallowed then
    
                end if 
     
    Last edited: May 27, 2013
  2. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,143
    • Thanks Thanks x 1
  3. roach

    roach BANNED BANNED

    Joined:
    Sep 8, 2009
    Messages:
    740
    Likes Received:
    395
    thank you jazzc I appreciate you. :)
     
    • Thanks Thanks x 1