|
Sezotove wrote: Private Sub showTAX(ByVal decTAX As Decimal)
decTAX = dblSTATE_TAX + dblCOUNTY_TAX
End Sub
Even if decTax is a member, passing it in locally means you set the value of the local, not the member.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
well how can i get the decTAX to go from being local to a member? because that would be why the following subs are not calling the correct variable... but i still need the decTAX to be done in that method.
|
|
|
|
|
Don't pass it in. If you don't create a local variable with that name, then the member one will stay in scope.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Better still put all of this into a prober object orientated model, as .Net is and object orientated language.
If you had it all in a class called Product, with properties for PurchaseAmount and so on then your Main can just create a new Product object, set the purchase amount and call the methods on the Product object to display the results.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
No worries, i fixed it by making all the declared variables in the first method as globals, and did all the math calculations in a single method and had the others out put them. I dont quite know if this is what my teacher wants... but oh well its what im giving him.
|
|
|
|
|
Hello all
i am making a lap counter
and i am trying to calculate the avarage time from 5 laps
i have each lap time in a text box i tryed this and it did not work
Dim mymath as string
mymath = textbox1.text + textbox2.text + textbox3.text + textbox4.text + textbox5.text / 5
msgbox = (mymath)
but it dont work
can anyone help me
Thanks agine
Bob
|
|
|
|
|
use
mymath = (CSng(textbox1.Text) + CSng(textbox2.Text) + CSng(textbox3.Text) + CSng(textbox4.Text) + CSng(textbox5.Text))/5
I think this would work.
|
|
|
|
|
There is no such thing as averaging string together, so I'm not surprised this didn't work.
Convert each string in your textboxes to TimeSpan objects. You can then easily get the number of milliseconds in each TimeSpan, average those together and create a new TimeSpan object with the result. This will give you the ability to easily convert the result to a String you can display in the correct format.
|
|
|
|
|
Hi Dave
i looked it up and tryed a few thing but i cant get it to work
can i have a example please ???
Thanks
Bob
|
|
|
|
|
You convert a string in a TextBox to a TimeSpan using:
Dim timeIntervals(5) As TimeSpan
' 5 hours, 21 minutes, 40 seconds
TimeSpan.TryParse("5:21:40", timeIntervals(0))
You can add all of the time intervals together like this:
Dim avgTime As New TimeSpan
For i As Integer = 0 to 4
avgTime = avgTime.Add(time(i))
Next
And then average the times:
avgTime = New TimeSpan(avgTime.Ticks / 5)
|
|
|
|
|
Hello everyone
how can i make a button do one thing when click and when you click it agine it will somting else and so on
somting like this
click once = code1
click twice = code2
click three time = code3
click a forth time = code4
on and on
Thanks
Bob
|
|
|
|
|
Two ways. One is to have a class level variable that will hold the click count. Checking that, you can execute the appropriate code. Or you can use the Tag property of the button serving the same purpose. Although you will need to cast that to integer every time you use it.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
There is another option.
You can create methods that handles each of the clicks and just within each handler write this below so that once the code gets executed it will remove its handler and attach another handler to it.
RemoveHandler btn.click, addressof btn_click
AddHandler btn.click, addressof btn2nd_click
|
|
|
|
|
Hi everyone,
I am inserting date into y sql database from DateTimePicker Control. The code is as follows:
Dim joindatetime As String, joindate As String
joindatetime = DateTimePicker.Value.ToString
joindate = Format(joindatetime, "Short Date")
for example, the output "joindate" is "12/02/2009".
Now, when I am inserting this "joindate" value into my database, I found that in database column, the entry is not Date i.e. "12/02/2009" but it is both date and time i.e. "12/02/2009 12:40 PM".
What I want is to enter the "12/02/2009" only into the database without the time value.
Hope my query is clear,Can someone help me out on this?
Thanks
|
|
|
|
|
First try: DateTimePicker1.Value.ToShortDateString
Regards:
Robert
|
|
|
|
|
you don't store numbers as strings, do you?
so you shouldn't store dates and times as strings, both programming languages and SQL-like languages have special types for date and time information. Using them offers extra functionality (e.g. comparing dates, picking date parts) and shield you from formatting issues (regional settings, dd/mm/yy versus mm-dd-yyyy and many more).
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
If you are using SqlServer 2008 there are Date , Time , DateTime , SmallDateTime , DateTime2 and DateTimeOffset datatypes. Pick the one which fits your use.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
You should spend some time thinking about what it is you're doing. What happens if you want to display the date in a different format later ? What if you want to search for all objects within a date range ? These are the reasons you store a date as a date and let the presentation layer worry about how a date should be presented.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Try the following transact-sql..
SELECT CONVERT(CHAR(10), GETDATE(), 103)
convert a DateTime ('2004-06-24 06:01:40.000') to a simple date format ('dd/mm/yyyy' )
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
I'm a newbie to VB.NET and I' m trying to write a small Windows forms app that searches a network drive for a folder and reads the specified file. It seems like the best approach would be to use the System.IO classes to search the directory and open the files. My question is do I need to open a socket and use the Network Stream object to access this network file? If the computer is just a terminal already connected to the network is this required or do I simply need file permissions on that machine to access the file?
Any advice would be greatly appreciated!!
|
|
|
|
|
rbc1025 wrote: do I simply need file permissions on that machine to access the file?
Correct.
If it's just a regular network share, you can access it just like a local file.
|
|
|
|
|
Thanks Ian. I didn't have all the details of the network when I was posting. I feel a bit ignorant as I realized it would obviously appaer as virtual drive to the networked machine. Thanks for your response!
|
|
|
|
|
I agree with you.. But i think it will cover on local environment not remote...
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
If you can already see the directory the files are in using standard Directory and File methods, why would you need to open a socket to the server to read the file?? You just open the file like you would any other local file on your machine.
|
|
|
|
|
Thanks Dave! I realized shortly after I posted this that it would appear as a simple drive on the networked machine. I didn;t have all the details before I posted but I thank you all the same.
|
|
|
|