Solved

Text Box that can change dynamically?

Posted on 2000-03-31
10
149 Views
Last Modified: 2010-05-02
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.
0
Comment
Question by:boorna00
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 14

Expert Comment

by:wsh2
ID: 2673779
Never saw the movie.. please explain more.. <lol> and a <smile>.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2673786
you mean generate random letters and numbers before stopping on the correct one?
0
 
LVL 3

Expert Comment

by:jjmartin
ID: 2673840
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:wsh2
ID: 2673948
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
 
LVL 32

Expert Comment

by:Erick37
ID: 2674046
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
 
LVL 28

Expert Comment

by:AzraSound
ID: 2674055
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
 
LVL 28

Accepted Solution

by:
Ark earned 100 total points
ID: 2675453
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
 
LVL 28

Expert Comment

by:AzraSound
ID: 2675459
We have enough code here we can make a sequel to that movie now  =)
0
 
LVL 28

Expert Comment

by:Ark
ID: 2675472
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
 

Author Comment

by:boorna00
ID: 2685045
Thank you everyone for you help.  Ark's answer is the one that worked out the best.

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question