Text Box that can change dynamically?

Did anyone see the movie War Games where the computer clicked through a bunch of characters before displaying it on the screen.  That is what I need to do with a pre-determinted 14 character output.  If anyone has any ideas please let me know.
boorna00Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ArkConnect With a Mentor Commented:
Hi
May I take part at this to? Like wsh2, I've never seen this movie, but saw many other with "password generations". IMHO, in Hollywood they would make something like this:
'AzraSound - sorry, I was so lazy to declare variables that I got yours

Private m_strChars As String
Private m_intCount As Integer
Private m_intLimit As Integer
Private myString As String
Private currString As String
Private i As Integer, n As Integer

Private Sub Form_Load()
   myString = "StRiNg TO tYpE"
   Label1.Font.Size = 18
   Label1.Font.Bold = True
   Timer1.Interval = 50
   Timer1.Enabled = False
     
   m_strChars = "1234567890abcdefghijklmnoprqstuvwxyzABCDEFGHIJKLMNOPRRSTUVWXYZ "
   m_intCount = 0
   m_intLimit = 50
   Timer1.Enabled = True
   currString = String$(14, " ")
   Label1.Caption = currString
End Sub

Private Sub Timer1_Timer()
   If m_intCount > m_intLimit Then
      n = n + 1
      i = Rnd * 14 + 1
      Mid$(currString, n, 1) = Mid$(myString, n, 1)
      m_intCount = 0
   Else
      m_intCount = m_intCount + 1
      For i = n + 1 To 14
          Mid$(currString, i) = Mid(m_strChars, (Rnd * Len(m_strChars) + 1), 1)
      Next i
   End If
   Label1 = currString
   If Label1.Caption = myString Then Timer1.Enabled = False
End Sub

' If you need, you can change Label with Text

Cheers
0
 
wsh2Commented:
Never saw the movie.. please explain more.. <lol> and a <smile>.
0
 
AzraSoundCommented:
you mean generate random letters and numbers before stopping on the correct one?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
jjmartinCommented:
Try this...
Create a form, with a command button named command1, and a text box named text1 and copy this code to the form:

Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


Private Sub Command1_Click()
Dim i As Integer
Dim s(6) As String
s(0) = "a"
s(1) = "b"
s(2) = "c"
s(3) = "d"
s(4) = "e"
s(5) = "f"
For i = 0 To 5
    Text1.Text = s(i)
    DoEvents
    Sleep 500
Next i
End Sub

You can control the speed of the scrolling by increasing or decreasing the sleep value.
0
 
wsh2Commented:
Ohhhhh.. Azra I think you got it !!!! Ok, here is a very simple example.. <smile>

1. Start a new Standard.Exe project.
2. Add 2 Labels to your form.. and name them Label1 and Label2.
3. Add 2 Timers to your form.. and name them Timer1 and Timer2.
4. Copy and Paste the following into the code window.

<----- Copy Begin ----->

Option Explicit
Private m_strChars As String
Private m_intCount As Integer
Private m_intLimit As Integer

Private Sub Form_Load()
   
   Label1.Caption = ""
   Label1.Move 10, 10, 1000, 1000
   Label1.FontSize = 40
   Label1.FontBold = True
   Label1.FontItalic = False
   
   Label2.Caption = ""
   Label2.Move 1000, 10, 1000, 1000
   Label2.FontSize = 40
   Label2.FontBold = True
   Label2.FontItalic = False
   
   Timer1.Interval = 50
   Timer1.Enabled = False
   Timer2.Interval = 50
   Timer2.Enabled = False
   
   m_strChars = "ABCDEFGHIJKLMNOPRRSTUVWXYZ"
   m_intCount = 0
   m_intLimit = 50
   Timer1.Enabled = True

End Sub

Private Sub Timer1_Timer()

   If m_intCount > m_intLimit _
   Then
      Timer1.Enabled = False
      Label1.Caption = "H"
      Label1.FontItalic = True
      m_intCount = 0
      Timer2.Enabled = True
   Else
      m_intCount = m_intCount + 1
      Label1.Caption = Mid(m_strChars, _
         (Rnd * Len(m_strChars) + 1), _
         1)
   End If
   Label1.Refresh
   
End Sub
Private Sub Timer2_Timer()

   If m_intCount > m_intLimit _
   Then
      Timer2.Enabled = False
      Label2.Caption = "I"
      Label2.FontItalic = True
   Else
      m_intCount = m_intCount + 1
      Label2.Caption = Mid(m_strChars, _
         (Rnd * Len(m_strChars) + 1), _
         1)
   End If
   Label1.Refresh
   
End Sub

<----- Copy End ----->


0
 
Erick37Commented:
Here's another:

Option Explicit

Private sString As String
Private sTmp As String
Private sBuild As String
Private lPos As Long

Private Sub Command1_Click()
    Text1.Text = ""
    Timer1.Enabled = True
End Sub

Private Sub Form_Load()
    Text1.Text = ""
    sString = "OneTwoThreeFour"
    lPos = 1
    Timer1.Enabled = False
    Timer1.Interval = 55
    Randomize
End Sub

Private Sub Timer1_Timer()
    If (Text1.Text = sString) Then
        Timer1.Enabled = False
        Exit Sub
    End If
    'Rnd range values
    Dim lUpper As Long, lLower As Long
    'String (character) to match
    Dim sSearch As String
    sSearch = Mid(sString, lPos, 1)
    'Restrict random search to range
    lUpper = Asc(sSearch) + 5
    lLower = Asc(sSearch) - 5
    'Pick a random char
    sTmp = Chr(Int((lUpper - lLower + 1) * Rnd + lLower))
    'Test for match
    If sSearch = sTmp Then
        lPos = lPos + 1
        sBuild = sBuild & sTmp
        Text1.Text = sBuild
    Else
        Text1.Text = sBuild & sTmp
    End If
End Sub
0
 
AzraSoundCommented:
wsh2 I modified yours a bit to suit what I think boorna is looking for using one label and one timer:



Private m_strChars As String
Private m_intCount As Integer
Private m_intLimit As Integer
Private myString As String
Private currString As String
Private i As Integer



Private Sub Form_Load()
   myString = "STRING TO TYPE"
   
   Timer1.Interval = 50
   Timer1.Enabled = False
   
   m_strChars = "ABCDEFGHIJKLMNOPRRSTUVWXYZ "
   m_intCount = 0
   m_intLimit = 50
   Timer1.Enabled = True

End Sub

Private Sub Timer1_Timer()

   If m_intCount > m_intLimit Then
      Label1.Caption = Left(myString, i)
      currString = Label1.Caption
      m_intCount = 0
      i = i + 1
   Else
      m_intCount = m_intCount + 1
      Label1.Caption = currString & Mid(m_strChars, _
         (Rnd * Len(m_strChars) + 1), _
         1)
   End If
   Label1.Refresh
   If Label1.Caption = myString Then Timer1.Enabled = False
End Sub


0
 
AzraSoundCommented:
We have enough code here we can make a sequel to that movie now  =)
0
 
ArkCommented:
Let's start? :-)
I hope they haven't copyright for this "Password generating" method.
BTW, about code, I forgot to remove this string:
i = Rnd * 14 + 1
First time I tried to set correct letters randomly, but, IMHO, from beginning to end is better
Cheers
0
 
boorna00Author Commented:
Thank you everyone for you help.  Ark's answer is the one that worked out the best.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.