|
Easiest way is to add Module as we do in vb6 and declare your variables there.
|
|
|
|
|
Better way. Create a class that holds your "global" variables and declare them Public Shared.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave, congrats on the MVP nod.
just a quick related question. i've read in places that declaring public properties in your forms is bad practice. i read this after having already implemented this in an mdi project of my own. any idea on why this technique is a bad idea? this is actually how i implement the above situation i.e. our user logs into the application then i expose a "User" property from my main form for use throughout the application. i've never had any problems with this technique and was just curious.
-jim
-- modified at 10:21 Friday 21st April, 2006
|
|
|
|
|
It is always a good idea to separate your GUI from your business objects (in this case user would be one). Think OOP it gives you more flexibility.
Think if you had a project that was done in windows forms and you got a new requirement to create a web front end. If you create global variables in your forms you will have to duplicate this logic in your web page. If this was a class in an external dll (which all business objects should be in a separate project) , all you would have to do is reference the dll in the web project and the functonality is there.
Hope this helps.
Mike Lasseter
|
|
|
|
|
Thanks!
Mr's right, at least as far as I can figure out. I've never seen any documentation that says, definitively, that it's bad practice. Just, like here, everyone saying it's taboo. The most reasonable explanation that I could come up with was business logic.
Keep the form-related, visual UI stuff, in the form code and the application logic in seperate classes. This would include "global" variables that you need to share between MDI documents. I've always just created a class or two that did nothing but hold my "global" stuff, complete with Property wrappers. It actually makes it easier to track whats going on too. You don't have to go to multiple forms to find out "where on earth did I declare this crap!?"
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 11:37 Friday 21st April, 2006
|
|
|
|
|
I had written some fairly decent code in VB.NET 2003 to print out a listing of my video and recipe collections. Multiple pages, columns, small pictures etc. I imported the VB2003 programs into VB Express and although the main body of the programs worked quite well, the print routines just FROZE up everything. There were no compiling errors or runtime errors. I had to Cntl/Alt/Del to unlock everything. Any ideas of what is wrong?
Thanks
|
|
|
|
|
Put a breakpoint at the start of the Printpage() event and trace through until it freezes?
Or but trace.writeline code in the app to see what is going on?
(Without looking at the code I can't be any more helpful, sorry)
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
I wanted to run multiple files in media player from the vb.net code. So can anyone suggest me how can I solve this problem.
|
|
|
|
|
Create a PlayList[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hi,
I have developed a VB.net project in 800 X 600 resolution.
Now i deployed in a computer which is having 1024 x 768 Resolution.
It is not covering whole screen and looking bad.
any process by which it will adjust automatically....by the screen resolution.
cheers
Paritosh
|
|
|
|
|
Nope. You have to resize your form to fit, if needed. You're form also has to be designed to compensate for varying sizes. This means anchoring controls so they stay in the spots you want them and can resize themselves accordingly. Check out the Archor property, among othet things, of just about every visual control in your form.
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 9:00 Friday 21st April, 2006
|
|
|
|
|
What is the way to check for EndOfStream while using a Binary Reader ? StreamReader has the EndOfStream Property, but there seems to be no equivalent Property in BinaryReader. I am using BinaryReader because I am dealing with Byte Arrays, and sadly, StreamReader seems to insit on reading Character Arrays. And, the Stream I am reading doesn't support Seeking, so we cannot check if the Position Property is equal to the Length...
I googled for it, but can't seem to find anything. Any help people ?
Yuvi Panda T
Microsoft Student Partner
Blogs at : http://yuvipanda.blogspot.com
|
|
|
|
|
Yuvi Panda wrote: and sadly, StreamReader seems to insit on reading Character Arrays
That's what it was designed to do! From the MSDN docs on StreamReader:
StreamReader Class
Implements a TextReader that reads characters from a byte stream in a particular encoding.
As for the BinaryReader[^], you're looking for it's <a href="http://msdn2.microsoft.com/en-us/library/system.io.binaryreader.peekchar.aspx" rel="nofollow">PeekChar</a>[<a href="http://msdn2.microsoft.com/en-us/library/system.io.binaryreader.peekchar.aspx" target="_blank" rel="nofollow" title="New Window">^</a>] method.
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 8:57 Friday 21st April, 2006
|
|
|
|
|
Thanks, but I am reading from a Network Stream, which Does Not support Peeking.
Yuvi Panda T
Microsoft Student Partner
Blogs at : http://yuvipanda.blogspot.com
-- modified at 22:44 Friday 21st April, 2006
|
|
|
|
|
Hello there,
I found a wayout to check for the end of stream.
<br />
using (BinaryReader br = new BinaryReader(fs))<br />
{<br />
while(fs.Position<fs.Length)<br />
{<br />
}<br />
}<br />
...assuming that "fs" is defined as the FileStream in the outer block.
Hope this works...
Mafaz
|
|
|
|
|
Hi all,
Can anybody tell abt the VB's chr() function equivalent in vc++ ?
|
|
|
|
|
In C++ doesn't exists.
Example:
VB:
Chr(13)
C++:
char mychr = 13;
|
|
|
|
|
One is not really needed in C++, but the compiler mite complain.
Implicit conversion:
char ch = 10; // compiler mite complain
Explicit conversion:
char ch = char(10); // compiler happy
Explicit conversion:
char ch = (char)10; // compiler happy
INTP
Every thing is relative...
|
|
|
|
|
Hi!
I have a table with about 50000 rows of data. if the user's search is not specific it returns not less than 200 records and i want to make their search as specific as possible.
say if they type A i want to scan a data in the database as soon as user types A i need to display
Accord
Amber
A..
those matching records are in database once they type AC
the matching record should anything after AC from database. i dont know what control do i need to use may be combo control dont know.. please help or direct me to any article that has something that i am after
thanks very much
|
|
|
|
|
Is this windows or web application?
--------------------------------------------------------
My development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Dear all,
----my aaplicationis WINDOWS APPLICATION----
How to display data of two database table (EMPLOYEE AND SALARYDATA ) into Crstal Report according to selection of month and year in windows application. actually only employee name data coming from employee table and rest of all data(i.e. total,hra,basic,gross,) coming from salrydata table. How can i solve this problem help me plz
|
|
|
|
|
|
i am getting problem in executing oracle procedure in vb.net
i am using adodb connection. Oracle Procedure accept 6 input parameters and return back 3 parameters. I know how to pass parameters using oledb. But problem is that i have to do it using adodb as per requirement.
Pleasee help me in solving this query.
Thanks in advance
Manish
|
|
|
|
|
we are trying to create a login for our application, but its not working, we know that we need the code to check against the database to see that the password and the login is correct but our code doesnt seem to work.
The code is:
If my.User.isauthenticated then
Textuser.text=my.User.name
If userexixts(my.user.name) then
Textpassword.focus()
Else
MyNewUser = true
Messagebox.show("Please chose the Reguest Account link")
End if
Else
messagebox.show("Contact help if you are a Auckland University Staff member")
|
|
|
|
|
What do you mean by "doesn't seem to work"?
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|