Solved

Text Box that can change dynamically?

Posted on 2000-03-31
10
141 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
  • 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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 27

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 27

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating VB6 Function 19 59
JSON Response and request in VB6 application 11 407
MS Access - Capture pressed key onclick 4 33
VB 6 error 5 in windows 10 but not in XP 7 55
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 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