Results 1 to 40 of 178

Thread: VB - A Program Registration Scheme

Hybrid View

  1. #1
    New Member
    Join Date
    Aug 2005
    Posts
    4

    Re: VB - A Program Registration Scheme

    What would I have to remove and fix, if I wanted it so it skipped the automatic outlook email, and just popped up the manual email form where it says an error has occured, please use your email system to manually send and email to....

    Could someone tell me what I need to do?

    PS: Im very very new to VB and have no idea what to do on my own.

    -Sidewinder

  2. #2

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: VB - A Program Registration Scheme

    You are much better off creating an installation package so the user will be able to use MAPI but here you go.

    VB Code:
    1. Public Sub ShowStep1()
    2.  
    3.     cmdNext.Caption = "&Next >"
    4.     cmdBack.Enabled = True
    5.     lblReg.Caption = "Step 1 - Request Registration Key"
    6. [HL="#FFFF80"]'    lblExplain.Caption = "Pressing Next will generate an " _
    7. '                       & "E-mail requesting a Registration Key. When you receive " _
    8. '                       & "that key via return E-mail, you can finish the " _
    9. '                       & "registration process by completing the " & optRegStep(1).Caption _
    10. '                       & " step, (Step 2)."
    11.     lblExplain.Caption = "Press Next and then send me an " _
    12.                        & "E-mail as you will be instructed to. When you receive " _
    13.                        & "that key via return E-mail, you can finish the " _
    14.                        & "registration process by completing the " & optRegStep[/HL](1).Caption _
    15.                        & " step, (Step 2)."
    16.    
    17.     optRegStep(0).Visible = False
    18.     optRegStep(1).Visible = False
    19.     lblName.Visible = True
    20.     txtName.Visible = True
    21. [HL="#FFFF80"]    'new
    22.     txtName.Text = "Press Next"
    23.     txtName.Enabled = False[/HL]
    24.  
    25.     lblRegKey.Visible = False
    26.     lblRegisterTo.Visible = False
    27.     txtRegisterTo.Visible = False
    28.     txtRegKey(0).Visible = False
    29.     txtRegKey(1).Visible = False
    30.     txtRegKey(2).Visible = False
    31.     lblDash1.Visible = False
    32.     lblDash2.Visible = False
    33.    
    34. [HL="#FFFF80"]'    txtName.SetFocus[/HL]
    35.  
    36. End Sub
    37.  
    38. Public Function RequestKey() As Boolean
    39.  
    40. '    Dim strCriteria As String
    41.     Dim mpSession As MAPISession
    42.     Dim mpMessages As MAPIMessages
    43.    
    44.     On Error GoTo ErrorRoutine
    45.    
    46.     ' This causes this validation (for step 1) to
    47.     ' be bypassed when going directly to step 2
    48.     If txtName.Visible = False Then
    49.         RequestKey = True
    50.         Exit Function
    51.     End If
    52.    
    53.     If Trim(txtName) = "" Then
    54.         MsgBox "Please enter your name.", _
    55.              vbExclamation, REG_ERR_TITLE
    56.         txtName.SetFocus
    57.         m_StepCompleted = m_StepCompleted - 1
    58.         Exit Function
    59.     End If
    60.    
    61.     Screen.MousePointer = vbHourglass
    62.     Me.Hide
    63. [HL="#FFFF80"]'    frmWait.Show
    64. '
    65. '    gRegClass.Subject = StrConv(LCase(App.EXEName), vbProperCase) & " Registration Request"
    66. '
    67. '    Set mpSession = MAPISession1
    68. '    Set mpMessages = MAPIMessages1
    69. '
    70. '    mpSession.DownLoadMail = False
    71. '    'show the logon interface for the mail
    72. '    mpSession.LogonUI = True
    73. '    'sign on to selected account
    74. '    mpSession.SignOn
    75. '
    76. '    DoEvents
    77. '
    78. '    'check if logon was successful
    79. '    If mpSession.SessionID = 0 Then
    80. '        'SendMAPIMail = False
    81. '        MsgBox "Error On login To MAPI", _
    82. '        vbCritical, "MAPI"
    83. '        Exit Function
    84. '    End If
    85. '
    86. '    'set the session IDs the same on both objects
    87. '    mpMessages.SessionID = mpSession.SessionID
    88. '
    89. '    'Set the MSgIndex to -1, this needs to be
    90. '    'done for the Compose event to work
    91. '    mpMessages.MsgIndex = -1
    92. '    'compose a new message
    93. '    mpMessages.Compose
    94. '
    95. '    'don't show the resolve address interface
    96. '    mpMessages.AddressResolveUI = False
    97. '
    98. '    'set the recipient
    99. '    mpMessages.RecipIndex = 0
    100. '    mpMessages.RecipType = mapToList
    101. '    mpMessages.RecipAddress = EMAIL
    102. '    'resolve the recipient's email addresses
    103. '    mpMessages.ResolveName
    104. '
    105. '    'set the subject
    106. '    mpMessages.MsgSubject = gRegClass.Subject
    107. '
    108. '    'set the Message/Body/NoteText
    109. '    mpMessages.MsgNoteText = txtName & " " & GetSerialNumber
    110. '
    111. '    'send the message
    112. '    mpMessages.Send
    113. '
    114. '    'close the current session
    115. '    mpSession.SignOff
    116. '
    117. '    'clear objects
    118. '    Set mpMessages = Nothing
    119. '    Set mpSession = Nothing
    120. 'new
    121.     MsgBox "Send me an email which includes your name and this number." _
    122.             & vbCrLf & vbCrLf & GetSerialNumber[/HL]
    123.     Screen.MousePointer = vbNormal
    124.    
    125.     Unload Me
    126.     DoEvents
    127.    
    128.     RequestKey = True
    129.     Unload frmWait
    130.    
    131.     Exit Function
    132.    
    133. ErrorRoutine:
    134.  
    135.     Set mpMessages = Nothing
    136.     Set mpSession = Nothing
    137.    
    138.     Screen.MousePointer = vbNormal
    139.    
    140.     frmRegError.Show vbModal
    141.     m_StepCompleted = m_StepCompleted - 1
    142.     RequestKey = False
    143.     Err.Clear
    144.  
    145. End Function

  3. #3
    Hyperactive Member divined's Avatar
    Join Date
    Aug 2004
    Location
    Thessaloniki, Greece
    Posts
    447

    Re: VB - A Program Registration Scheme

    I`m using your code as a foundation to my own registration scheme. It`s been very instructive and helpful. One thing I`d like to ask is why do you tell that the main form of my program has to be loaded in modal mode. My main form is an MDI container form and it crashes when I try to load it in modal mode.
    Last edited by divined; Sep 8th, 2005 at 06:13 AM.
    SteadFast!

  4. #4

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: VB - A Program Registration Scheme

    Because in the code below if frmDone wasn't shown modally, the code would continue through the unloading of all forms and the immediate ending of the program.
    VB Code:
    1. Public Sub Main()
    2.  
    3.     Dim frm As Form ' Create a Form object
    4.    
    5.     GetAppEnvironment ' Calls the routine that finds out if the user is registered
    6.    
    7.     If Not gRegClass.Registered Then ' Registered is a boolean property of theCRegister class
    8.         frmRegister.Show vbModal ' If the user is not registered then the register form is displayed
    9.     Else
    10.         frmDone.Show vbModal ' In this app if the user is registered then frmDone is displayed.
    11.                              ' In your app you would probably replace frmDone with your main form
    12.     End If
    13.    
    14.     For Each frm In Forms ' Loop through all the forms...
    15.         Unload frm        ' and unload them...
    16.         Set frm = Nothing ' and set them to Nothing
    17.     Next
    18.    
    19.     End ' 99.99999% of the time not needed, but it can't hurt after you've unloaded your forms.
    20.  
    21. End Sub

  5. #5
    Hyperactive Member divined's Avatar
    Join Date
    Aug 2004
    Location
    Thessaloniki, Greece
    Posts
    447

    Re: VB - A Program Registration Scheme

    I`m not doing it exactly that way. I load my main MDI form in non-modal mode. Then , I just unload the form showing the splash screen. All, others forms are unloaded when the main MDI form is closed. So, effectively the program does not terminate. Is there any defect to this method?
    SteadFast!

  6. #6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width