Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. About using Module in VB.NET 2003

About using Module in VB.NET 2003

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasemysqlvisual-studio
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    drexler_kk
    wrote on last edited by
    #1

    Dear all, I'm using a main module to shared all the Public variable and certain main component that my system is running. I'm using VB.NET using Visual Studio 2003 connect with MySQL 5.0 database. My system is running with Window Form Application which is a small Point Of Sales System used by my sister grocery shops. Problems that facing by me now is the module doesn't continue running after I used System.Windows.Forms.Application.Run(FrmLogin) inside my main module class. The following are the code used: Sub Main() TerminalLocate = ConfigurationSettings.AppSettings("Location") TerminalID = ConfigurationSettings.AppSettings("Terminal_ID") If TerminalLocate = "" Then MessageBox.Show("No Location Detected !") Exit Sub End If If TerminalID = "" Then MessageBox.Show("No Terminal Detected !") Exit Sub End If Dim FrmLogin As New FrmLogin 'FrmLogin is used for user verification for the system login. FrmLogin.Visible = False FrmLogin.WindowState = FormWindowState.Normal System.Windows.Forms.Application.Run(FrmLogin) '--------------------Code after this line never run anymore--------------------------------------- While UserLoginSuccessful = True Dim clsReceipt As New clsDBReceipt clsReceipt.FindLastReceipt(TerminalLocate, TerminalID) MessageBox.Show("The Receipt number =" & strReceiptNo1 & " ") End While End Sub Anyone can give me some idea how to get back the system to run back to my module and do the continous task inside my module? My next task is to get the last receipt and transaction number from the database. Thanks for reading and hope someone can help me soon. Regards Drex

    G M 2 Replies Last reply
    0
    • D drexler_kk

      Dear all, I'm using a main module to shared all the Public variable and certain main component that my system is running. I'm using VB.NET using Visual Studio 2003 connect with MySQL 5.0 database. My system is running with Window Form Application which is a small Point Of Sales System used by my sister grocery shops. Problems that facing by me now is the module doesn't continue running after I used System.Windows.Forms.Application.Run(FrmLogin) inside my main module class. The following are the code used: Sub Main() TerminalLocate = ConfigurationSettings.AppSettings("Location") TerminalID = ConfigurationSettings.AppSettings("Terminal_ID") If TerminalLocate = "" Then MessageBox.Show("No Location Detected !") Exit Sub End If If TerminalID = "" Then MessageBox.Show("No Terminal Detected !") Exit Sub End If Dim FrmLogin As New FrmLogin 'FrmLogin is used for user verification for the system login. FrmLogin.Visible = False FrmLogin.WindowState = FormWindowState.Normal System.Windows.Forms.Application.Run(FrmLogin) '--------------------Code after this line never run anymore--------------------------------------- While UserLoginSuccessful = True Dim clsReceipt As New clsDBReceipt clsReceipt.FindLastReceipt(TerminalLocate, TerminalID) MessageBox.Show("The Receipt number =" & strReceiptNo1 & " ") End While End Sub Anyone can give me some idea how to get back the system to run back to my module and do the continous task inside my module? My next task is to get the last receipt and transaction number from the database. Thanks for reading and hope someone can help me soon. Regards Drex

      G Offline
      G Offline
      Grant Porteous 0
      wrote on last edited by
      #2

      Hi Drex, I believe your problem lies in creating another process to run your login form. I believe you can call your login form by calling the "ShowDialog" method. Here is a way to do it:

          Dim frm As FrmLogin
      
          Dim dlgResult As DialogResult
      
          frm = New FrmLogin
      
          dlgResult = frm.ShowDialog
      
          If dlgResult = Windows.Forms.DialogResult.OK Then
      
              '---- do your receipt check here
      
          End If
      

      You would need to implement logic in the login form to return "Windows.Forms.DialogResult.OK" ONLY if the user logged in correctly. Also, I strongly recommend that you not do the "While" loop to check for your receipts. VB is perfect for using event - that is, do not loop infinitely - respond to events that happen in your application. Calling the login form how I have above will help get you there. You could even raise an event when the user has successfully logged in, and then do your receipt check. Hope that helps. Regards, Grant __________________ Grant Porteous Your Software Licensing Guide http://www..SerialKeyMaker.com

      D 1 Reply Last reply
      0
      • D drexler_kk

        Dear all, I'm using a main module to shared all the Public variable and certain main component that my system is running. I'm using VB.NET using Visual Studio 2003 connect with MySQL 5.0 database. My system is running with Window Form Application which is a small Point Of Sales System used by my sister grocery shops. Problems that facing by me now is the module doesn't continue running after I used System.Windows.Forms.Application.Run(FrmLogin) inside my main module class. The following are the code used: Sub Main() TerminalLocate = ConfigurationSettings.AppSettings("Location") TerminalID = ConfigurationSettings.AppSettings("Terminal_ID") If TerminalLocate = "" Then MessageBox.Show("No Location Detected !") Exit Sub End If If TerminalID = "" Then MessageBox.Show("No Terminal Detected !") Exit Sub End If Dim FrmLogin As New FrmLogin 'FrmLogin is used for user verification for the system login. FrmLogin.Visible = False FrmLogin.WindowState = FormWindowState.Normal System.Windows.Forms.Application.Run(FrmLogin) '--------------------Code after this line never run anymore--------------------------------------- While UserLoginSuccessful = True Dim clsReceipt As New clsDBReceipt clsReceipt.FindLastReceipt(TerminalLocate, TerminalID) MessageBox.Show("The Receipt number =" & strReceiptNo1 & " ") End While End Sub Anyone can give me some idea how to get back the system to run back to my module and do the continous task inside my module? My next task is to get the last receipt and transaction number from the database. Thanks for reading and hope someone can help me soon. Regards Drex

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        We do the login and validation BEFORE we do the application.run(frmmain). Display Login form which does the user validation and returns a boolean (and in our case a table of permissions) If the user is validated then do the application.run to your main form, presumably your POS entry point.

        Never underestimate the power of human stupidity RAH

        D 1 Reply Last reply
        0
        • G Grant Porteous 0

          Hi Drex, I believe your problem lies in creating another process to run your login form. I believe you can call your login form by calling the "ShowDialog" method. Here is a way to do it:

              Dim frm As FrmLogin
          
              Dim dlgResult As DialogResult
          
              frm = New FrmLogin
          
              dlgResult = frm.ShowDialog
          
              If dlgResult = Windows.Forms.DialogResult.OK Then
          
                  '---- do your receipt check here
          
              End If
          

          You would need to implement logic in the login form to return "Windows.Forms.DialogResult.OK" ONLY if the user logged in correctly. Also, I strongly recommend that you not do the "While" loop to check for your receipts. VB is perfect for using event - that is, do not loop infinitely - respond to events that happen in your application. Calling the login form how I have above will help get you there. You could even raise an event when the user has successfully logged in, and then do your receipt check. Hope that helps. Regards, Grant __________________ Grant Porteous Your Software Licensing Guide http://www..SerialKeyMaker.com

          D Offline
          D Offline
          drexler_kk
          wrote on last edited by
          #4

          Hello Grant Porteous and all, I am sorry for my late reply here because my internet connection down for the past few days here. I have try to put the code into my system but I have no idea how should I return a result of Windows.Forms.DialogResult.OK from my Login form. How should I return it from my Login form to my main module to run the continues data about the receipt after the user login verification? What I did now in my project is after user login verification successful,I'll Hide the Login form and directly pass the main form which is the Point-Of-Sales form (FrmPOSTerminal). I would like to know am I doing the right design for my system to pass the directly after the verification inside my Login form to my main form Point-Of-Sales form or I should hide my Login form and open my form using the Sub Main Module?? Hope someone can give me some idea about this. Thanks for reading. Regards Drex

          1 Reply Last reply
          0
          • M Mycroft Holmes

            We do the login and validation BEFORE we do the application.run(frmmain). Display Login form which does the user validation and returns a boolean (and in our case a table of permissions) If the user is validated then do the application.run to your main form, presumably your POS entry point.

            Never underestimate the power of human stupidity RAH

            D Offline
            D Offline
            drexler_kk
            wrote on last edited by
            #5

            Hello Mycroft and all , Currently my system is directly running the Main Module to do everything here. I use this design because I allowed the user to do some counter setting when the system loads. The user can change the receipt setting such as receipt starting number,counter name,receipt allignment and the selection of database profile as what I'm trying to develop it now. But I'm still wondering am I doing the right design for this? Because I read some forum said that we shouldn't used the Main Module anymore in order to make our system totally object oriented. So,do you all have any idea about using Main Module for VB.NET langguage on doing window form application system?? Hope to hear someone opinion here about this. Thanks for reading. Regards Drex

            modified on Sunday, July 27, 2008 11:51 PM

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups