|
Thanks! You're right, though: This may be WAY more work than it is worth. I'll have to plow around source code for a while...
If anyone else has any other solutions, please let me know.
|
|
|
|
|
Hello,
I am new to vb.net and I need to know how to pull the value of a certain field from a dataset that i have already filled, to use for to compare to the users input in an if statement.
Thanks for the help
Mariscal
|
|
|
|
|
Im not too sure if this is what you are trying to do but:
if form1.DataName1.Data1 = form1.DataName2.Data2
|
|
|
|
|
I assume that your Dataset (lets call it ds) has a single table.
So the nth field of mth row will be :
ds.Tables(0).Rows(m).Item(n)
"I think there is a world market for maybe 5 computers"
Thomas Watson, chairman of IBM, 1943
"There is no reason anyone would want a computer in their home"
Ken Olson, chairman & founder of Digital equipment, 1977
"This 'telephone' has too many shortcomings to be seriously considered as a means of communication. The device is ingerently of no value to us."
Western Union internal memo, 1876
"640 K ought to be enough for anybody."
Bill Gates, 1981
"Computers in the future may
|
|
|
|
|
Thanks for the help Pradeep C
Santana
|
|
|
|
|
I am having problems trying to change a number into a dollar amount. For example, an object = $10.50, it will only allow me to have 10.5. I am not sure how or what to do to have it with the dollar sign and with 2 decimal places if it = $10.00.
Thank you,
ibok23
|
|
|
|
|
If this is 'old' VB, check out Format$.
Steve S
|
|
|
|
|
Fomat would be under properties right? I do not have that under my properties. I am using visual basic.net.
Thank you,
ibok23
|
|
|
|
|
You're a real beginner at this aren't you?
What you would do is store the decimal version of the currency in a variable. THen when you need to show the value in a currency format, you supply the Format specification. Something like this:
Dim amount As Single
amount = 10.5
Console.WriteLine("Amount is " & Format(amount, "Currency"))
Console.WriteLine("Amount is " & Format(amount, "C"))
Console.WriteLine("Amount is " & Format(amount, "$###,##0.00"))
All three Format specifications do the exact same thing. The one exception is the "Currency" and "C" specifications will use the format of the Windows Locale currentcy format, specified in the Regional and Language Options Control Panel.
RageInTheMachine9532
|
|
|
|
|
Yes, I am a newbie. I have a box that is going to = $10.00. So I would write:
dim baserate as double = 84.5
costofroom.text = Console.writeline(Format(amount,"Currency"))
am i close
Thank you,
ibok23
|
|
|
|
|
Not quite...
I'm assuming you have a TextBox on your Form called costofroom. I'm also assuming that you want the 'baserate' to be displayed in the TextBox and not 'amount' like in my example code.
dim baserate as double = 84.5
costofroom.text = Format(baserate,"Currency")
RageInTheMachine9532
|
|
|
|
|
sorry about that.. i tried.
ok, I have put that in.. have not tried one more error.
if I have $0.00 dollars as the amount for a box additonalguestcharge.text
I put...
additionalguesstcharge.text = format(0,"currency")
getting an error..but of course.
now what.
By the way thanks for all the input.
Thank you,
ibok23
|
|
|
|
|
Try this...
Dim amount as double
amount = 10.5
Console.Writeline(amount.ToString("C"))
Free your mind...
|
|
|
|
|
maybe try
Console.Writeline(Format(0,"$#,###0.00"))
i havent tried this but i remember i used something just like it before, i forget exactly what it was. mess around with that if it gives an error. itll b just around the corner.
------------------------
Jordan.
III
|
|
|
|
|
First, what's the error?
RageInTheMachine9532
|
|
|
|
|
i am not sure. I just now ran the problem and I received a yellow arrow at one of my endifs.
Not sure what to do.
Thank you,
ibok23
|
|
|
|
|
I finally got it done. Now i am haveing problems with my total.
I am trying to add three boxes together. I love math and I know what to do. I put
total.text = ((subtotal.text) + (additionalguestcharge.text) + (rollbed.text))
in my answer it gives me
$209.00$5.00$10.00
instead of adding it up.
This is weird.
Thank you,
ibok23
|
|
|
|
|
I have to leave, be back in one hour if I need to. Thanks again.
Thank you,
ibok23
|
|
|
|
|
ibok23 wrote:
total.text = ((subtotal.text) + (additionalguestcharge.text) + (rollbed.text))
That's because you adding String of characters together, not number values. What's going to make you redesign your code is the fact the the numbers you see in the TextBoxs can't be used in calculations. TextBoxs are lousy places to keep number values. You should only use them to display results.
Since I can't see all of your code, I can't tell you exactly what you have to do to make things right, but I can tell you you need to keep the value you use in calculations in numeric type variables. You also need to rename your TextBoxes so that their names don't conflict with any other variable names. I would suggest renaming them with a 'txt' prefex, like this:
total becomes txtTotal
subtotal becomes txtSubTotal
additionalguestcharge becomes txtAdditionalGuestCharge
...
Now, keep your numeric values in variables something like this:
Dim subtotal As Double
Dim additionalguestcharge as Double
Dim rollbed as Double
Dim total as Double
total = subtotal + additionalguestcharge + rollbed
txtTotal.Text = Format(total, "C")
Get the idea?
RageInTheMachine9532
|
|
|
|
|
Thanks - I see what I was doing wrong, I don't understand it all the way, but I do see.
Now one more question if you don't mind
How do you get to set a date picker back to the current date when you push the clear button?
I want them to be able when they push the clear button to default back to the current date.
|
|
|
|
|
Anonymous wrote:
I want them to be able when they push the clear button to default back to the current date.
Easy enough ... just set the Value property of the DateTimePicker control to the current Date using Now(). Put this code in the handler for the Clear button click:
dtpArrival.Value = Now()
dtpCheckout.Value = Now()
RageInTheMachine9532
|
|
|
|
|
when adding text in labels, textboxes, etc etc, you must convert them to a number first. they are concatenating (putting together) the text, with what you are doing right now. do something like:
total.text = CInt(CInt(subtotal.text) + CInt(additionalguestcharge.text) + CInt(rollbed.text))
------------------------
Jordan.
III
|
|
|
|
|
I am having to write a code to figure out how many days are from the starting of a project and the ending of the project. I am using the date picker and I have the day of the week, Month, day and year on both the starting and ending. How do I write a code to figure out how many days are in between?
Thank you,
ibok23
|
|
|
|
|
VB.NET Example
Dim FirstDate As Date
Dim SecondDate As Date
Dim days As Integer
Dim hours As Integer
Dim minutes As Integer
'Your DatePicker control would capture these dates
FirstDate = Now()
'I add 3 days just for example sake
SecondDate = DateAdd(DateInterval.Day, 3, FirstDate)
'Use datediff to calculate in days, then hours, then minutes
days = DateDiff(DateInterval.Day, FirstDate, SecondDate)
hours = DateDiff(DateInterval.Hour, FirstDate, SecondDate)
minutes = DateDiff(DateInterval.Minute, FirstDate, SecondDate)
Hope this helps
Gregory J Lynch
Hack
|
|
|
|
|
This does help. If I only want to find out about how many days do I still need to do the minute and hour (Dim)?
Dim hours As Integer
Dim minutes As Integer
hours = DateDiff(DateInterval.Hour, FirstDate, SecondDate)
minutes = DateDiff(DateInterval.Minute, FirstDate, SecondDate)
Do I type in this part at the bottom or does the date picker automatically do it?
'Your DatePicker control would capture these dates
FirstDate = Now()
'I add 3 days just for example sake
SecondDate = DateAdd(DateInterval.Day, 3, FirstDate)
Thank you,
ibok23
|
|
|
|