|
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:
<br />
Sub Main()<br />
TerminalLocate = ConfigurationSettings.AppSettings("Location")<br />
TerminalID = ConfigurationSettings.AppSettings("Terminal_ID")<br />
<br />
If TerminalLocate = "" Then<br />
MessageBox.Show("No Location Detected !")<br />
Exit Sub<br />
End If<br />
<br />
If TerminalID = "" Then<br />
MessageBox.Show("No Terminal Detected !")<br />
Exit Sub<br />
End If<br />
<br />
Dim FrmLogin As New FrmLogin 'FrmLogin is used for user verification for the system login.<br />
FrmLogin.Visible = False<br />
FrmLogin.WindowState = FormWindowState.Normal<br />
System.Windows.Forms.Application.Run(FrmLogin)<br />
<br />
<br />
'--------------------Code after this line never run anymore---------------------------------------<br />
While UserLoginSuccessful = True<br />
<br />
Dim clsReceipt As New clsDBReceipt<br />
clsReceipt.FindLastReceipt(TerminalLocate, TerminalID)<br />
MessageBox.Show("The Receipt number =" & strReceiptNo1 & " ")<br />
End While<br />
<br />
End Sub<br />
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
Hello all,
Can somebody help me with this.
I have a BindingNavigator and DataGridView both are looking to the same BindingSource.
The BindingNavigator works fine.
When I do a RowFilter on the DataTable and I set the DataGridView.DataSource to the filterd DataTable the content in the DataGridView is filtered but the BindingNavigator doesnt work anymore.
The record count in the BindingNavigatorCountItem has it’s old value and the navigation buttons don’t work on the DataGridView.
How can I set the BindingNavigator to the filtered DataSource or How to sync it with the DataGridView?
To get the CountItem correct BindingNavigator.BindingSource.DataSource = Filtered DataTable
But the Button's stil don't work
Thanks,
Marco
|
|
|
|
|
To answer my own question...
Only do a filter on BindingNavigator.BindingSource.Filter
|
|
|
|
|
I have a legacy VB6 application that needs to use a .NET component.
I am attempting to pass values to the component, but continually get the message "wrong number of values or invalid property assignment".
Any help would be appreciated in terms of:
resolving error or
determining how to pass values correctly or
using properties for the componenent instead
It would have been nice to be able to test the solution in advance, but, this is a production environment and the required equipment was not available until today.
Thanks,
Tim
|
|
|
|
|
I think (I have not done thissince 2002) that the .Net component has to have a com wrapper to make it accessible by VB6. This is an option when building the component.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi, I made a application which connect to microsft outlook via MSMAPI32.DLL.
i have deployed this application in the client machine.
When this application try to access microsoft outlook. it give error :
Creating an instance of the COM component with CLSID {00000010-0000-0010-8000-00AA006D2EA4} from the IClassFactory failed due to the following error: 80040112
I dont know what to do with this problem. I checked all the dependencies of MSMAPI32.DLL. All dependencies are available in the client machine.
Kindly help me.
hi, this is anirudh
|
|
|
|
|
Why are connecting to Outlook via MSMAPI32.DLL? Why not reference the Outlook APIs?
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
Dear Steve,
Thank you so much for quick response. There is always some problem occurs when using vb6 component in vb.net. However Outlook APIs can be used, but it does not solve the problem regarding using vb6 component to .net.
Kindly guide me so that i am able to use this dll in VB.Net.
hi, this is anirudh
|
|
|
|
|
First off, I'm in the "skilled hobbyist" category - I don't do this for a living and my apps are not commercial apps. However, I've distributed some of my apps to colleagues who in some cases find them very useful. My question (when I get to it) will concern: how do I make sure what works on my machine will work on their machines?
I am coding an app that is working fine for me. Its job is just to create "recipes" for mixing chemical solutions. Really it's a glorified calculator, but with time-savers like allowing you to save molecular weights of commonly-used chemicals, jumping to websites that contain chemistry databases, organizing your library of chemicals by user-defined groupings, etc.
One can just run the calculations and write down the results. But I decided to provide a way to store recipes in a log - you can run several calculations and build a document of the recipes for saving or printing. Rather than code a mini word processor, I decided I'd just have the code open Microsoft Word. Now, to questions:
In my program I declare a global variable:
Public log As Word.Application
I noticed if I declared this "as new" then Word began running in the background. So in the File... Open log even of the menu, the code is:
btnCopyToLog.Enabled = True
Try
log.Visible = True
Catch
Dim openit As New Word.Application
log = openit
log.Visible = True
openit = Nothing
End Try
log.Documents.Add()
I'm doing it this way to get the global variable to reference the Word app. I probably will wrap this all in a Class once I have a clear vision of how it all will work. Right now, the btnCopyToLog Click event has another Try...Catch to write text to the ActiveDocument. The Form Closing event sets log to Nothing.
My question is this: it works for me. But if I send it to another person who doesn't have Microsoft Word 2003, what will happen? Will the app fail to run because there is a reference to the Microsoft Word 11.0 library? Or will the app run but throw a run-time error at the "log" variable declaration? (Is this fatal since declarations can't be error trapped?) Or will the app only throw an error when the variable is used? (In which case I can error trap it.) What if the user has a newer or older version of Word?
Thank you in advance for any guidance you can offer. I can always make my own log window with a rich text box if need be. But I'd also like to learn more about the issues involved, since I plan another program that will rely on Excel.
|
|
|
|
|
Steven,
IIRC, I believe it is required that Word be installed on the computer for that to work. I used to have that documented somewhere but I can't find it right now.
|
|
|
|
|
I'm sure that's true! What I'm wondering is what the behavior of the program will be. If there's a way for the program to discover if Word is on the machine I'd like to programmatically provide a different option to the user. (E.g., if a Word command fails then copy the text that would have gone to word to the clipboard, or generate an appending log text file.)
UPDATE:
Won't matter for the question I don't think, but I've encapsulated all of the Word operations into its own class.
|
|
|
|
|
Ah! Ok, I think (again from my bad memory) that it will crash (trying to load the reference). I didn't try this[^], but if it works, you might could check if Word is installed first. Actually, I don't have Word here so I will try it and let you know...
Update:
It hosed with: System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154.
I hope this is helpful and that I didn't completely miss your question. I've done it before.
modified on Monday, July 21, 2008 2:50 PM
|
|
|
|
|
Steven St. John wrote: Will the app fail to run because there is a reference to the Microsoft Word 11.0 library? Or will the app run but throw a run-time error at the "log" variable declaration?
It should work until the point of instantiating the new word application. The client computer will need to have Office 2003 or newer installed in order to work.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
The JZ - That link you gave on the Registry function was very helpful!
Paul Conrad - The info you gave me was just what I was looking for, with the bonus info that a Word 2007 user would also be able to run things.
So, this should work:
Public Class SolutionLog
Dim log As Word.Application
Dim m_WordVer As String
Dim m_CanUseWord As Boolean
Public Sub New()
Dim regKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.ClassesRoot
Dim regWord As Microsoft.Win32.RegistryKey = regKey.OpenSubKey("Word.Application")
If Not (regWord) Is Nothing Then
Dim regWordVer As Microsoft.Win32.RegistryKey = regWord.OpenSubKey("CurVer")
m_WordVer = regWordVer.GetValue("")
If m_WordVer = "Word.Application.11" Then m_CanUseWord = True
Else
m_WordVer = "Word Not Installed"
m_CanUseWord = False
End If
End Sub
When my program creates an instance of the SolutionLog class upon loading, the registry is checked and m_CanUseWord is set if and only if Word is found and uses Version 11 (I'll add Version 12 to this eventually, and possibly parse the string and use a >= logic). I'll make this value and the m_WordVer value available to the client program as ReadOnly properties. The methods that start Word and type to Word can be error trapped:
If Not(m_CanUseWord) Then
Throw New Exception
Else
log=New Word.Application
End If
The only reason it might not work is the first line:
Dim log As Word.Application
Does that cause an error? Or will it be okay since I never actually create a new Word.Application except in an error-trapped if... then? Since the code is already compiled when it gets to the user's machine, I'm assuming this will not cause an error and my problem is solved.
If I'm Right Then
Thank you all very much!
Else
There must be some way to do this
End If
|
|
|
|
|
Hiii
i want to add a task in windows task scheduler using vb.net 2005.
how i do this.please suggest.
Thanx
~Khatri Mitesh
|
|
|
|
|
|
|
Odd question of the day: Can you have multiple font colors in same text on single statusstriplabel?
I have a status strip with multiple statusstrip labels. I want to produce something like this:
Refresh ("R" displayed as the color Red and "efresh" in black). I tried creating 2 different status labels, but the text is displayed to far apart (even after modifying the alignment and padding). So is it possible to have multiple fonts assigned to different sections of the text within the same label?
I told you..... it's an odd question
|
|
|
|
|
That is not possible with the label control of the System.Windows.Forms namespace. You can create a control that could emulate this and then embed the custom control in the status strip, but other than that I am not aware of any other ways around it.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
|
You should look to use a Rich Text Box control and embed that onto your status bar control
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|