Question using Timer in VB6.0

I have some query about my code, I am using VB6.0 and I have a problem using TimerControl. The user will first Login[frmLogin] and then he will be redirected to the EmployeeForm[frmEmployee] after the Timer[tmLogin]/Progressbar[pgLogin] reaches 100%.

Here is my code:

Private Sub cmdContinue_Click() If Me.txtUserID.Text = "" Or Me.txtPassword.Text = "" Then MsgBox "Required field must not be a null.", vbCritical, "ERROR" Else Do Until datLogin.Recordset.EOF With datLogin.Recordset If Me.txtUserID.Text = !empid And Me.txtPassword.Text = !Password Then 'Here Else datLogin.Recordset.MoveNext End If End With Loop MsgBox "User ID and Password didn't match!", vbCritical, "ERROR LOGIN" End If End Sub

Here is my code for Timer:

Private Sub tmLogin_Timer() With Me.pbLogin Me.pbLogin.Value = Me.pbLogin.Value + 1 Me.lblLoginPercent.Caption = Str(Me.pbLogin.Value) + "%" If Me.pbLogin.Value >= 1 And Me.pbLogin.Value < 50 Then Me.lblConnecting.Caption = "Connecting..." ElseIf Me.pbLogin.Value >= 50 And Me.pbLogin.Value < 100 Then Me.lblConnecting.Caption = "Logging in..." Else Me.lblConnecting.Caption = "Done..." frmLogin.Hide frmEmployee.Show Me.tmLogin.Enabled = False Exit Sub End If End With End Sub

-------------Problems Reply------------

You should be aware that the timer event only fires as long as there is no other processing being done in you application.

You could try to do it in the following way :

Private Sub cmdContinue_Click()
Dim boolLoggedIn As Boolean

If Me.txtUserID.Text = "" Or Me.txtPassword.Text = "" Then
MsgBox "Required field must not be a null.", vbCritical, "ERROR"
Else
Do Until datLogin.Recordset.EOF
With datLogin.Recordset
If Me.txtUserID.Text = !empid And Me.txtPassword.Text = !Password Then
boolLoggedIn = true
Exit Do
Else
datLogin.Recordset.MoveNext
End If
End With
Loop

If boolLoggedIn Then
'While the timer is running frmLogin will still accept user
'input, so you should disable the form to prevent that.
'You should also consider closing the recordset if it isn't
'going to be needed further on.
tmLogin.Enabled = true
Else
MsgBox "User ID and Password didn't match!", vbCritical, "ERROR LOGIN"
End If
End If
End Sub

The timer event will only start to fire once this sub has exited and no other code is running.

Category:vb6 Views:0 Time:2011-04-06
Tags: vb6

Related post

  • Question about CreateObject() in VB6 / VBA 2008-12-05

    I can do this: Dim fso As New FileSystemObject or I can do this: Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") How do I know what string to use for CreateObject? For example, how would I know to use the "Scripting." part of "

  • Status of VB6/ Best Desktop Application Language with Native Compilation 2010-04-04

    I was looking for a Desktop Application Programming Language with one of the biggest constraint: - “I need to output as native executable”. I explored multiple options: Java is not a very good option for desktop programming, but still you can use it.

  • Dependency/NDepend type tools for VB6 2010-10-11

    This question talks about Vb6/.Net but all the answers address the .Net aspects but not the VB6 aspects. Would anyone know of tools that allow a simillar kind of graphing/dependency try to be created for VB6 apps. I assume that it would have be done

  • Why Doesn't a Global Var Declared in one VB6 project Compile in Another Project in same VB6 Project Group? 2011-03-28

    I apologize that this is such an elementary question. Our VB6 project group contains 6 projects plus the UI project containing all the app's forms. We generate a uniqueID (gstrUniqueImportUuid) in the code behind one of the forms, which must be expos

  • What is a WSDL file and how do I use it in VB6/VBA 2012-04-02

    I have just installed QAS Pro Web on a computer and I am now trying to figure out how to programmatically access the service from another computer. So far I have worked out that the QAS ProWeb installation has opened port 2021 on my computers' firewa

  • ADO Windows With SP1 and VB6 2012-04-30

    I've been reading about the GUIDs changing for ADO/MDAC in Windows 7 service pack1 for VB6 apps. I need to recopile my compontents and replace the deprecated ones with the new one. My question is if my VB6 app is only going to be installed on windows

  • VB6 executable will not run, error: Error Number 429 ActiveX component can't create object 2014-08-13

    returns this error: Error Number 429 ActiveX component can't create object, I have selected compatibility mode, set it to XP sp3, still get the same error, when I select the troubleshoot option to report to microsoft, it displays incompatible applica

  • CGZIPLibrary.dll not compressing files 2011-05-27

    HI, I am using CGZipLibrary.dll in my code for zipping the files. A .zip file is being created but the file is not getting compressed. The original file and the .zip file are of same size. Please provide some suggestions. Thanks in advance. ---------

  • What is this "Of Date" in VB? 2011-07-06

    I have a function which excepts a string and Of Date is passed. What is that? myfunc(Of Date)() --------------Solutions------------- As mentioned in a comment to your question, this is not vb6, and can never be used in vb6; it's VB.Net, which is real

  • how to a detect my process has superuser privileges in windows os 2011-07-27

    how to a detect my process has superuser privileges in windows os. for example i would like to detect if my ie explore is using superuser privilege my account is administrators groups or normal user groups --------------Solutions------------- Use the

  • How to MySQL query with Visual Basic 6 2011-07-30

    two things: first: I have googled everywhere, including stackoverflow. Just about questions regarding sql vs vb6 are about connection string. I have this down pat. Any reference to mysql queries are for the query itself - but not in tangent with vb6

  • VB6 convert to VB.net Variant question 2009-12-02

    I have been tasked to convert out VB6 program to VB.NET. In my research online everyone seems to say I need to go through my code and get rid of any Variants I have. I have had pretty good luck so far, but I am having an issue in replacing this one.

  • randomly generate 40 questions in vb6? please help me 2010-01-30

    i've been trying to create a vb6 code that will randomize 10 questions but it's not working. i use sql as my database here's my code: Private Sub cmdNext_Click() Dim real_ans As String Dim nCnt As Integer 'nCnt = nCnt + 2 'Label3.Caption = nCnt real_

  • VB6 - Windows API call to DnsQuery - Function and Pointer Question 2010-02-13

    In VB6 I'm making a call to the Windows API DnsQuery. Private Declare Function DnsQuery Lib "dnsapi" Alias "DnsQuery_A" ( _ ByVal lpstrName As String, _ ByVal wType As Integer, _ ByVal Options As Long, _ ByVal pServers As Long, _ ppQueryResultsSet As

  • VB6: Question about version numbers of dependent OCXs 2010-06-16

    Is it important for a VB6 app to refer to certain OCX versions? I have noticed that if I put my VB6 app code through the IDE on one machine then the form files will refer to different version of some OCXs than if I use another machine. What is the ru

  • Question about Timer Control in VB6 2011-04-07

    I have some query about my code, I am using VB6.0 and I have a question using TimerControl... The user will first Login[frmLogin] and then the UserID and Password must recognize whether it is Admin or Guest. Once it was recognized as Admin, the user

  • VB6 File IO questions (FreeFile, File Number, and Dir command) 2011-10-26

    I'm converting an old VB6 app that's been chugging along for years, but has a server name hard-coded into it. We want to convert it to a C# app, and I'm doing OK reading most of the VB6 code, except I'm not 100% sure I'm reading the code right when i

  • VB6 SQL 2005 Database Index Question 2009-09-09

    I have a VB app that accesses a sql database. I think it’s running slow, and I thought maybe I didn’t have the tables propery indexed. I was wondering how you would create the indexes? Here’s the situation. My main loop is Select * from Docrec Order

  • How to create a simple install system for VB6 on XP/Vista and newer? 2008-08-23

    Heavy emphasis on simple. I've never made an installer and I'd rather not have to learn much. A system that I could hand a pile of files to and it would make some smart guesses about where to put them would be ideal. Go ahead and answer the general q

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.194 (s). 11 q(s)