I'm trying to figure out how to add a registry key to my program. I have a program that needs to run on 3 seperate machines simultainiously(sp) and 1 of those machines needs to be set to primary while the others have to be secondary. This is so that the maintenance subroutines that I created don't run on all 3 machines. I thought that using a registry key would be the best idea to store something along the lines of wether it is the primary machine or the secondarys. If anyone could help or can think of a better way to do this that would be great.
Thank you,
Tazzy
Comments
:
: Thank you,
: Tazzy
=====================================================================
Hi,
You could use the TAG property and put this code in a
PROGRAM-START button.
Just another idea, this code makes it switchable at run-time then. :-)
You can then disable routines based on this value. ;-)
[code]
Private Sub Command1_Click()
Dim setPrimary As Integer
setPrimary = MsgBox("Set this machine to primary?", vbYesNo, "Set primary?")
If setPrimary = vbYes Then
Command1.Tag = "Y"
Else
Command1.Tag = "N"
End If
End Sub
[/code]
Regards,
Dr M.
: Hi,
:
: You could use the TAG property and put this code in a
: PROGRAM-START button.
:
: Just another idea, this code makes it switchable at run-time then. :-)
:
: You can then disable routines based on this value. ;-)
:
: [code]
: Private Sub Command1_Click()
: Dim setPrimary As Integer
: setPrimary = MsgBox("Set this machine to primary?", vbYesNo, "Set primary?")
: If setPrimary = vbYes Then
: Command1.Tag = "Y"
: Else
: Command1.Tag = "N"
: End If
: End Sub
: [/code]
:
:
: Regards,
:
: Dr M.
:
******************************************************************
Dr M.
I tried using the Tag Property and it's not allowing me change or disable the subs. Here is the code I used.
[code]
'this section is supposed to actually perform the sub-routines
If (frmWhoIs3.Tag = "Y") Then
If (DateDiff("s", m_dtTrigger, Now) >= 0) Then
If (DateDiff("s", m_dtTrigger2, Now) >= 0) Then
Timer1.Enabled = False
'Do the maintence
maintSub
End If
Else
If (DateDiff("s", m_dtTrigger, Now) <= 0) Then
If (DateDiff("s", m_dtTrigger2, Now) >= 0) Then
Timer1.Enabled = False
'do Daily maintenance
maintSub2
End If
End If
End If
'End If
'this section is supposed to run a Masking page during the time that the maintenance actually goes off.
ElseIf (frmWhoIs3.Tag = "N") Then
If (DateDiff("s", m_dtTrigger, Now) >= 0) Then
If (DateDiff("s", m_dtTrigger2, Now) >= 0) Then
Timer1.Enabled = False
'Run Mask During Maintence
maintSub3
End If
Else
If (DateDiff("s", m_dtTrigger, Now) <= 0) Then
If (DateDiff("s", m_dtTrigger2, Now) >= 0) Then
Timer1.Enabled = False
'Run Mask During Maintence
maintSub4
End If
End If
Timer1.Enabled = False
End If
End If
[/code]
Am I doing something wrong?
Tazzy
Hi,
You are checking a condition that is the same 4 times.
Is this needed?
[code]
Private Sub Form_Load()
'this section is supposed to actually perform the sub-routines
If (frmWhoIs3.Tag = "Y") Then
If (DateDiff("s", m_dtTrigger, Now) >= 0) Then
[red][b]'I refer to this next one>> [/b][/red]
If (DateDiff("s", m_dtTrigger2, Now) >= 0) Then 'This condition (condition1) is the same as__
Timer1.Enabled = False ' |
'Do the maintence' |
maintSub ' |
End If ' |
Else ' |
If (DateDiff("s", m_dtTrigger, Now) <= 0) Then ' |
[red][b]'I refer to this next one>> [/b][/red]
If (DateDiff("s", m_dtTrigger2, Now) >= 0) Then 'this one.<----------------------------------
Timer1.Enabled = False
'do Daily maintenance
maintSub2
End If
End If
End If
'End If
'this section is supposed to run a Masking page during the time that the maintenance actually goes off.
ElseIf (frmWhoIs3.Tag = "N") Then
If (DateDiff("s", m_dtTrigger, Now) >= 0) Then
[red][b]'I refer to this next one>> [/b][/red]
If (DateDiff("s", m_dtTrigger2, Now) >= 0) Then '(condition1) again same as_
Timer1.Enabled = False ' |
'Run Mask During Maintence' |
maintSub3 ' |
End If ' |
Else ' |
If (DateDiff("s", m_dtTrigger, Now) <= 0) Then ' |
[red][b]'I refer to this next one>> [/b][/red]
If (DateDiff("s", m_dtTrigger2, Now) >= 0) Then '<-------------------------
Timer1.Enabled = False
'Run Mask During Maintence
maintSub4
End If
End If
Timer1.Enabled = False
End If
End If
End Sub
[/code]
[code]
Private Sub Main()
'this section is supposed to actually perform the sub-routines
If (frmWhoIs3.Tag = "Y") And DateDiff("s", m_dtTrigger, Now) >= 0 Then
Timer1.Enabled = False
'Do the maintence
maintSub
ElseIf (frmWhoIs3.Tag = "Y") And DateDiff("s", m_dtTrigger, Now) <= 0 Then
Timer1.Enabled = False
'do Daily maintenance
maintSub2
End If
'this section is supposed to run a Masking page during the time that the maintenance actually goes off.
If (frmWhoIs3.Tag = "N") And DateDiff("s", m_dtTrigger, Now) >= 0 Then
Timer1.Enabled = False
'Do the maintence
maintSub3
ElseIf (frmWhoIs3.Tag = "N") And DateDiff("s", m_dtTrigger, Now) <= 0 Then
Timer1.Enabled = False
'do Daily maintenance
maintSub4
End If
End Sub
[/code]
Why not do this?>>
Instead of loading a Form, Visual Basic can invoke a procedure to start an application.
To specify a startup procedure
1. Write a general Sub procedure called Main and save it in a standard module.
2. From the Tools menu, choose Options.
Visual Basic displays the Options dialog box.
3. Select the Project tab.
4. Select Sub Main from the Startup Form drop-down list box.
5. Choose OK.
When the project starts execution, Sub Main is called immediately.
Regards,
Dr M.
[code]
Private Sub Main()
'this section is supposed to actually perform the sub-routines
If (frmWhoIs3.Tag = "Y") And DateDiff("s", m_dtTrigger, Now) >= 0 And DateDiff("s", m_dtTrigger2, Now) >= 0 Then
Timer1.Enabled = False
'Do the maintence
maintSub
ElseIf (frmWhoIs3.Tag = "Y") And DateDiff("s", m_dtTrigger, Now) <= 0 And DateDiff("s", m_dtTrigger2, Now) >= 0 Then
Timer1.Enabled = False
'do Daily maintenance
maintSub2
End If
'this section is supposed to run a Masking page during the time that the maintenance actually goes off.
If (frmWhoIs3.Tag = "N") And DateDiff("s", m_dtTrigger, Now) >= 0 And DateDiff("s", m_dtTrigger2, Now) >= 0 Then
Timer1.Enabled = False
'Do the maintence
maintSub3
ElseIf (frmWhoIs3.Tag = "N") And DateDiff("s", m_dtTrigger, Now) <= 0 And DateDiff("s", m_dtTrigger2, Now) >= 0 Then
Timer1.Enabled = False
'do Daily maintenance
maintSub4
End If
End Sub
[/code]
Do you not want to take out all of the >=0 or <=0
and change them to <0 or >0 as on zero the condition
with <=0 is still TRUE when no time has elapsed as with >=0 ?
Regards,
Dr M.
: Hi,
:
: You are checking a condition that is the same 4 times.
: Is this needed?
: [code]
: Private Sub Form_Load()
: 'this section is supposed to actually perform the sub-routines
: If (frmWhoIs3.Tag = "Y") Then
: If (DateDiff("s", m_dtTrigger, Now) >= 0) Then
: [red][b]'I refer to this next one>> [/b][/red]
: If (DateDiff("s", m_dtTrigger2, Now) >= 0) Then 'This condition (condition1) is the same as__
: Timer1.Enabled = False ' |
: 'Do the maintence' |
: maintSub ' |
: End If ' |
: Else ' |
: If (DateDiff("s", m_dtTrigger, Now) <= 0) Then ' |
: [red][b]'I refer to this next one>> [/b][/red]
: If (DateDiff("s", m_dtTrigger2, Now) >= 0) Then 'this one.<----------------------------------
:
: Timer1.Enabled = False
:
: 'do Daily maintenance
: maintSub2
: End If
: End If
: End If
: 'End If
: 'this section is supposed to run a Masking page during the time that the maintenance actually goes off.
: ElseIf (frmWhoIs3.Tag = "N") Then
: If (DateDiff("s", m_dtTrigger, Now) >= 0) Then
: [red][b]'I refer to this next one>> [/b][/red]
: If (DateDiff("s", m_dtTrigger2, Now) >= 0) Then '(condition1) again same as_
: Timer1.Enabled = False ' |
: 'Run Mask During Maintence' |
: maintSub3 ' |
: End If ' |
: Else ' |
: If (DateDiff("s", m_dtTrigger, Now) <= 0) Then ' |
: [red][b]'I refer to this next one>> [/b][/red]
: If (DateDiff("s", m_dtTrigger2, Now) >= 0) Then '<-------------------------
:
: Timer1.Enabled = False
:
: 'Run Mask During Maintence
: maintSub4
: End If
: End If
: Timer1.Enabled = False
: End If
: End If
:
: End Sub
: [/code]
:
:
The reason it checks for the m_dtTrigger2 4 different times is due to it having a seperate date than the m_dtTrigger. If the time and date on those trigger are the same then in the first instance it performs a maintenance that includes a payroll sub. In the second one if the dates and times are different then is just performs the basic maintenance.
: [b][red]This message was edited by DrMarten at 2006-10-12 14:50:46[/red][/b][hr]
: [code]
: Private Sub Main()
: 'this section is supposed to actually perform the sub-routines
: If (frmWhoIs3.Tag = "Y") And DateDiff("s", m_dtTrigger, Now) >= 0 And DateDiff("s", m_dtTrigger2, Now) >= 0 Then
:
: Timer1.Enabled = False
: 'Do the maintence
: maintSub
:
: ElseIf (frmWhoIs3.Tag = "Y") And DateDiff("s", m_dtTrigger, Now) <= 0 And DateDiff("s", m_dtTrigger2, Now) >= 0 Then
:
: Timer1.Enabled = False
: 'do Daily maintenance
: maintSub2
:
: End If
:
:
:
: 'this section is supposed to run a Masking page during the time that the maintenance actually goes off.
: If (frmWhoIs3.Tag = "N") And DateDiff("s", m_dtTrigger, Now) >= 0 And DateDiff("s", m_dtTrigger2, Now) >= 0 Then
:
: Timer1.Enabled = False
: 'Do the maintence
: maintSub3
:
: ElseIf (frmWhoIs3.Tag = "N") And DateDiff("s", m_dtTrigger, Now) <= 0 And DateDiff("s", m_dtTrigger2, Now) >= 0 Then
:
: Timer1.Enabled = False
: 'do Daily maintenance
: maintSub4
:
: End If
:
: End Sub
: [/code]
:
: Do you not want to take out all of the >=0 or <=0
: and change them to <0 or >0 as on zero the condition
: with <=0 is still TRUE when no time has elapsed as with >=0 ?
:
:
: Regards,
:
: Dr M.
:
:
:
:
:
I can remove the <=0 and/or the >=0 and change them. That really isn't an issue.
Tazzy
Edit: NVM I'm an idiot. I found the problem.