AuthorMessage
Warrior
n00b
Posts: 18

Need help in coding a button that scrambles a name.U input a name and then u click the button and it scramles last 4 alphabets of the name. If someone can help me a little, it will be appreciated.
Thanks
Mickey
Ametuar
Posts: 115

If you can translate a Pascal routine to Basic I can do it in Pascal
But it shouldn't be that hard if you can access characters from a string directly. You can read the desired chars generate a random sequence of numbers of 1, 2, 3, 4 and write back  the read chars to string using the order you generated.
Of course it can be done in different ways. It was just an example.
Meka][Meka
Unstopable
Posts: 700

Quoted from Warrior
Need help in coding a button that scrambles a name.U input a name and then u click the button and it scramles last 4 alphabets of the name. If someone can help me a little, it will be appreciated.
Thanks

can you show me in en example string exactly what u want to happen in the routine ?
Mickey
Ametuar
Posts: 115

Quoted from Meka][Meka
can you show me in en example string exactly what u want to happen in the routine ?

If I am not wrong then:
Input: "Mickey"
Output: "Miykec"  <<----- last 4 chars scrambled.
It shouldn't be that hard to do.
Meka][Meka
Unstopable
Posts: 700

ok sorry i have not done vb6 for very very long time, but here this works....
Code:

Private Sub Form_Load()
'Scramble Code by Meka][Meka
'var
    Dim sNick As String, sChars As String, sBuild As String
    Dim iCount As Single, iRand As Single
'begin
    sNick = "Memphis"
    sChars = Right(sNick, 4) '//chars to scramble on end
       
    Randomize
   
    For iCount = 1 To 4
        If iCount = 4 Then
            sBuild = sBuild + sChars '//jus add the last char
        Else
            iRand = Round(Rnd * Len(sChars))
            sBuild = sBuild + Mid$(sChars, iRand, 1)
            Mid$(sChars, iRand, 1) = " "
            sChars = Replace(sChars, " ", "")
        End If
    Next iCount
   
    MsgBox "Scramlbed: " + sBuild
    MsgBox "Full String: " + Left(sNick, Len(sNick) - 4) + sBuild
           
    'cleanup
    sNick = vbNothing
    sChars = vbNothing
    sBuild = vbNothing
    iCount = vbNothing
    iRand = vbNothing
'end;
End Sub

just a little example ive quickly thrown together
ps: in delphi wud be much easier and much quicker
-/Meka][Meka
Warrior
n00b
Posts: 18

hehe thanks a lot.. it works..Thanks Meka and Mickey.. Thanks for your help 
Meka][Meka
Unstopable
Posts: 700

if u want to use MekaDLL, i will put it up for download, the code will then be much simpler, and the process will be much faster n lighter....
Code:

Private Sub Form_Load()
'Scramble Code by Meka][Meka ( Using MekaDLL )
'var
    Dim sNick As String, sScramble As String
'begin
    sNick = "Memphis"
    sScramble = Scramble(Right(sNick, 4)) '//chars to scramble on end
           
    MsgBox "Scrambled: " + sScramble
    MsgBox "Full String: " + Left(sNick, Len(sNick) - 4) + sScramble
           
    'cleanup
    sNick = vbNothing
    sScramble = vbNothing
'end;
End Sub

this would be the code using my component, its written in pascal so performance is great, infact i will add it to downloads in a few hours or so...
EDIT: ok uploaded, check here : http://www.meka-meka.com/forum/viewtopic.php?p=1364#1364
Warrior
n00b
Posts: 18

Thanks a lot Meka...  Appreciate it man