|
just separate your web business logic and data retrieval logic to a separate class library... u can use that in your Windows application, just you have to create the UI...
You may also use Web Services if you want to run the same code from both...
In that case windows application should be connected to internet or local network to run....
Abhishek Sur
|
|
|
|
|
Abhishek sur wrote:
You may also use Web Services if you want to run the same code from both...
Thanks Abhishek
Have you ever done like this before?
It will be better if you describe in brief how to use web service for the purpose you mentioned above.
Believe Yourself™ ™
|
|
|
|
|
Hi,
I have a form, which has toolstripcontainer with 4 toolbars. Problem is after adding toolstripcontainer, key down event of form is not fired. keypreview of form is set to true. key up is fired.
Please help..
modified on Friday, August 29, 2008 4:49 AM
|
|
|
|
|
I am not very good with percentages in calculations. I am writing in VB(.net 2005). I have 3 textboxes. One is current pay, and one is new pay. Both DOUBLE values. I need to have a calculation that finds the percentage of the increase in pay after the current pay and new pay are entered in the textboxes. I also need a calculation that allows the user to enter the current pay and percentage(the 3rd textbox) of the increase and calculate the new pay. So there are actually two calculations. Please someone help me out with this. I know to someone who is good with calculations and percentages can figure this one out fairly quickly. Thank you!!!
|
|
|
|
|
u can do like....
suppose u r taking 2 textboxes one for input the number and 2nd for input the percentage like 10% of 100.
now u can display the result in a label control like
dim a,b as integer
a=TextBox1.Text
b=TextBox2.Text
Label1.text=(a*b)/100
SSK.
Anyone who says sunshine brings happiness has never danced in the rain.
|
|
|
|
|
This is why you need other skills than just programming to be a good programmer.
You calculate the difference relative to the original amount. So you get:
percentage = ((newPay - oldPay) / oldPay) * 100
To calculate the new amount from the percentage, you can just convert the formula:
newPay = oldPay + (percentage / 100) * oldPay
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Wrong Forum...And In between, I don' t see any forum called Juniour School Problems at CP
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
What a ridiculous question to post in a progamming forum. If yuo don't know how to do calculations try Google, there are loads of pages devoted to all sorts of caluations from simple percentages to complex scientific formulae.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Look, if you have a problem with my post, DONT READ IT. Ive gone through this before on code project. Someone remarked that my post was dumb and shouldnt be here. Guess what? I dont really care whether you approve of my post being here or not. I know that most programmers enjoy writing equations and calculations so I was helping to give a couple of programmers something fun to do. And I do know how to do calculations, Im just not good with percentages. If you dont have something to add to the question I asked, dont post a reply. You are wasting your time trying to criticize people's posts in a forum. It is childish and rude. Dont you have something better to do with your time? Like I said, if you dont like it, DONT READ IT!!!!! That goes for the other guy that criticized my post too, both of you. Grow up and get a life!
On the upside though thank you for your suggestion on using Google. However I already tried searching the web to find a solution and had no luck. THATS WHY I CAME HERE...
|
|
|
|
|
Joey Picerno wrote: Look, if you have a problem with my post, DONT READ IT.
How do I know if I can help if I don't read it?
Joey Picerno wrote: I know that most programmers enjoy writing equations and calculations
I know a lot of programmers enjoy cooking, but I wouldn't ask for a recipe in a programmng forum
Joey Picerno wrote: However I already tried searching the web to find a solution and had no luck. THATS WHY I CAME HERE...
Not very good at Google either then. The top entry of http://www.google.co.uk/search?hl=en&q=how+to+calculate+percentage&meta=[^] tells you in easy to understand terms.
I, like most of the people who actually answer questions on CP and other forums, try and help those less experienced or who have real programming problems. To do this I have to read posts to see if I can help. There are more than enough questions posted where 2 minutes on Google would reveal the solution without people posting what, despite your claims, is nothing to do with programmng.
Finally,
Joey Picerno wrote: Ive gone through this before on code project. Someone remarked that my post was dumb and shouldnt be here
Joey Picerno wrote: That goes for the other guy that criticized my post too
Notice a trend here?
and don't worry, I won't waste my time readng any more of your ramblings.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Ashfield wrote: I know a lot of programmers enjoy cooking, but I wouldn't ask for a recipe in a programmng forum
Ashfield wrote: despite your claims, is nothing to do with programmng
So your saying that programmers never use calculations and equations???
Also, if my question had nothing to do about programming how was user "Guffa" able to give me a correct response with an equation that could be utilized in VB???
You arent making any sense and again are being very childish. Just drop it and go do something that is actually productive.
|
|
|
|
|
I have written a document imaging system in VB.Net, using Pegasus tool kit.
We have over 100 client's with no problems. However our latest client is experiencing problems. They have two users and both are having the same problem. The error message is to the affect:
"attempt to read or write to protected memory"
This is occuring after they open and close a scaning window numerous times over the course of 30 minutes.
I made sure that I disposed of all the Pegasus tools (put msgbox()) in the window's dispose method. I don't create any 'fancy' objects, although I do open file streams. But I make sure they are closed, as I do for Sqlconnections and data readers.
I put a garbage collector button in the parent window:
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()
MessageBox.Show("Done!" + vbCrLf + _
"Memory Allocated: " + GC.GetTotalMemory(False).ToString, "Garbage Collection")
I can see the memory usage going up everytime I instantiate a new window. What's interesting is that from run to run the amount reported by GetTotalMemory is always different.
Does anyone have any advice as how to approach this? Are there common VB objects that need to be manually disposed of?
Thanks!
|
|
|
|
|
dBrong wrote: I put a garbage collector button in the parent window
You really don't want to do this. Each time you call GC.Collect() you are freezing your applications main thread so the GC can run.
dBrong wrote: Are there common VB objects that need to be manually disposed of?
Any object that you are using that implements the IDisposable interface really should be cleaned up with a call to Dispose() or you should use it inside a using block.
You specifically mention that you are opening streams and database connections, but how are you making sure that they are closed properly? If you aren't using a try/finally or a using block to ensure that the Close() or Dispose() method is being called even if an exception occurs then you aren't guaranteed that the objects will get cleaned up properly. Going beyond streams and database connections, since you are in an document imaging system, any Graphics objects or any image objects (Bitmap , Image , etc.) also should be cleaned up by calling Dispose() .
These same rules apply for the Pegasus objects as well. If they aren't wrapped in a try/finally or a using block there is no guarantee that they are actually being cleaned up properly.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Scott,
Thanks for the response. I have a couple of questions:
I figure that memory usage should always be the same. However each time I start the app, and call GC.GetTotalMemory I get a different value!
Are there any system calls I can make to help me find out what's really happening with memory usage?
Secondly, is there a list of .net objects that explicity need dispose() to be called manually?
I'll wrap the close/dispose in try/catch. I was under the impression that if it failed I'd get a runtime error?
Thanks.
|
|
|
|
|
dBrong wrote: Are there any system calls I can make to help me find out what's really happening with memory usage?
There aren't any system calls you can make that I am aware of. There may be some unmanged Win32 API calls, but I'm not sure. The best option to see what is happening with the GC is to use some of the performance counters that are built in. Check this post[^] on Channel 9 for more information.
dBrong wrote: Secondly, is there a list of .net objects that explicity need dispose() to be called manually?
Unfortunately, there really isn't. The best option is to look at the following things:
- Does the object provide a
Close or Dispose method?
- Does the object inherit from
IDisposable ? You can also look at the MSDN documentation or use Reflector to check as well. The best rule of thumb is that if the object "feels" like it should be disposed of after you're done using it, it probably implements IDisposable .
dBrong wrote: I'll wrap the close/dispose in try/catch. I was under the impression that if it failed I'd get a runtime error?
It all depends on how your objects (or the objects you are using) are implemented. If for some reason a disposable object were to throw an exception that was caught and eaten your calling code may not know about it and/or the call to Dispose may never occur. By putting the call to Dispose inside of a finally or using block you can guarantee that it will get called under all conditions.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
dBrong wrote: is there a list of .net objects that explicity need dispose() to be called manually?
No, absolutely not. Such a list could never be complete, as the framework is growing with each new version, and there are thousands of thrird party libraries that contain objects that needs disposing.
If in doubt, check if the object has a Dispose method. If it does, there is a reason for that. Not every class that implements IDisposable needs disposing, but unless you have determined that it's actually not needed, you should always call the Dispose method if there is one.
Calling the Dispose method will not hurt even if it is not neccessary for that specific object. For example, you can close a SqlConnection object either by calling the Close method or the Dispose method, as the Dispose method makes sure that the Close method has been called. You can also call the Close method first, then the Dispose method, without harm. You can even call the Dispose method more than once on the same object without problems, you will never get an "object already disposed" error if you happen to call Dispose again.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Public Class Employee
Public Name As String = Nothing
Public Age As Integer = 0
End Class
Module Module1
Sub Main()
Dim emp1 As New Employee()
emp1.Name = "Calvin"
emp1.Age = 30
Console.WriteLine("Emp1: " & emp1.Name & ", " & emp1.Age)
Dim emp2 As New Employee()
emp2 = emp1
emp2.Name = "Bob"
emp2.Age = 40
Console.WriteLine("Emp1: " & emp1.Name & ", " & emp1.Age)
Console.WriteLine("Emp2: " & emp2.Name & ", " & emp2.Age)
Dim emp3 As Employee = emp1
emp3.Name = "Bryan"
emp3.Age = 50
Console.WriteLine("Emp1: " & emp1.Name & ", " & emp1.Age)
Console.WriteLine("Emp2: " & emp2.Name & ", " & emp2.Age)
Console.WriteLine("Emp3: " & emp3.Name & ", " & emp3.Age)
Console.Read()
End Sub
End Module
Here are the results when run:
Emp1: Calvin, 30
Emp1: Bob, 40
Emp2: Bob, 40
Emp1: Bryan, 50
Emp2: Bryna, 50
Emp3: Bryan, 50
My question is:
How can I copy Emp1 to Emp2 and then if I change the Emp2 only Emp2 is changed, Not Emp1.
|
|
|
|
|
You can create a Copy function on the Employee class that returns a shallow copy of the object.
Public Function Copy() As Employee
Return CType(Me.MemberwiseClone, Employee)
End Function
then say
Dim emp2 As Employee = emp1.Copy()
I noticed that your example doesn't really gain from having a copy of the object. I'm assuming you have some other case where you don't just override the copied data with new values, because if you just override the old values right away
|
|
|
|
|
The more correct method name would be Clone and potentially implementing the ICloneable interface.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
I did not recommend that interface because it is actually recommended against by Microsoft[^]. The general reason the interface is not recommended is that you do not know if it is a deep or shallow copy (which in this case does not matter), and there are no library functions that really use that interface anyway.
You are right though in suggesting the function name Clone, as it does seem to be more "standard."
|
|
|
|
|
Gideon Engelberth wrote: I did not recommend that interface because it is actually recommended against by Microsoft
You are absolutely correct. I had completely forgotten about this piece of guidance.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
The solution Gideon provided is the best one, although the method should be named Clone not Copy and you should possibly implement the ICloneable interface as well.
[modification: 28-Aug-2008]The ICloneable interface is actually not recommended[^] per the Framework Design Guidelines.[/modification]
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
modified on Thursday, August 28, 2008 11:51 PM
|
|
|
|
|
Thanks guys!
Gideon, yes I will be using it differently. I just used this example to test what happens. However, I still do not understand what is the difference between the following:
Dim emp1 As New Employee()
Dim emp2 as Employee = emp1 ' What is the difference between this
Dim emp2 as New Employee = emp1 ' and this
|
|
|
|
|
CodingYoshi wrote: Dim emp1 As New Employee()
That will declare the reference variable emp1, then it will create a new instance of the Emplyee class and assign it's reference to the variable.
CodingYoshi wrote: Dim emp2 as Employee = emp1
That will declare the reference variable emp2 and assign to it the reference from the varaible emp1. The result is two reference variables that are referencing the same object.
CodingYoshi wrote: Dim emp2 as New Employee = emp1
That doesn't compile at all, does it? You probably mean:
Dim emp2 as New Employee()<br />
emp2 = emp1
That will declare the reference variable emp2, create a new instance of the Employee class and assign it to the variable. Then it will throw away that instance and instead copy the reference from the emp1 variable. The result is two reference variables that are referencing the same object.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Suppose I have an application that takes orders and save them in an Access databse. And after taking each order I need to print a summary of that order. The summary should contain the items, prices, order number... I need to automatically print this summary right after I save the order. Can this be done in VB.net?
I tried to save the orders in a table called Order1 & the summary in a table called Summary. And I retrieved the need information from Summary to a new form. But this form is being only printed at run time, which I want to avoid?
So is there any way to automatically print the summary for each order, right after the order itself?
I am using a VB.Net application with an Access database.
Thank you in advance.
John,
|
|
|
|
|