|
OK. You've got a problem with the way your declaring your variables:
ibok23 wrote:
Private Const additionalguest as double = ((nudguest.text - 2) * 10) * Val(numberofdays.text))
The 'Const' means that the additionalguest variable will be a constant. Once it's defined, it can never be changed. You can't use the code in your if statement to change it. What you need to do is change the declaration of additionalguest:
Private additionalguest As Double = ((nudguest.text - 2) * 10) * Val(numberofdays.text))
For future reference, error messages are extremely important when asking us questions. Without the error message, we can only guess at what's wrong. Also, posting the code that you did was very helpful, keep it up! You can never post too much code! ...Well, within reason...
RageInTheMachine9532
|
|
|
|
|
It is still saying that the additionalguest is not declared. This is what I wrote.
This is all under the button to calculate.
Private additionalguest as double = ((nudguest.text - 2) * 10) * Val(numberofdays.text)) [I have an error on the last parenthesis - It says end of statement expected.]
if nudguest.text > 2 then
additionalguestcharge.text = additionalguest [I have an error under additonaguest - it says the additionalguest has not been declared]
additionalguestcharge.text = format (additionalguest, "currency")[I have an error under additonaguest - it says the additionalguest has not been declared]
Well what am I doing wrong now? lol
Thank you,
ibok23
|
|
|
|
|
ibok23 wrote:
Private additionalguest as double = ((nudguest.text - 2) * 10) * Val(numberofdays.text)) [I have an error on the last parenthesis - It says end of statement expected.]
You have to many parenthesis here, count the oppening and closing brackets, there should be one closing bracket ")" for each opening bracket "(".
I Think the code should be..
Private additionalguest as double = ((nudguest.text - 2) * 10) * Val(numberofdays.text)
Nadroj wrote:
since you have declared additionalguest as a private variable, it can only be accessed in the method it is defined
Nadroj is quite write, you cannot access the variable outside the code block in which you declared. From the code snipet you posted, we cannot see if you are doing this.
Have you tried declaring it a as class variable?
EG
Public Class myClass<br />
<br />
Private additionalguest as double<br />
<br />
'..other class declarations, methods etc<br />
<br />
Private Sub CalcCharges<br />
additionalguest = ((nudguest.text - 2) * 10) * Val(numberofdays.text)<br />
<br />
if nudguest.text > 2 then additionalguestcharge.text = additionalguest<br />
End Sub
Hope this helps
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
LearnVisualStudio.Net
|
|
|
|
|
ibok23 wrote:
This is all under the button to calculate.
Private additionalguest as double = ((nudguest.text - 2) * 10) * Val(numberofdays.text)) [I have an error on the last parenthesis - It says end of statement expected.]
OK. Since this is inside the Calculate button CLick handler, you don't need the Private. Also, the error emssage you got is because the parenthesis don't match up. You have 3 open parenthesis and 4 closing. They need to match exactly:
Dim additionalhuest as Double = ((nudguest.text - 2) * 10) * Val(numberofdays.text)
As for the rest, your best bet is to copy the entire Calculate button Click code to a post here. Paste between <pre> and </pre> tags, like this:
<pre>Private Sub Calculate_Click(...)
Some more code shows up here...
and some more...
End Sub</pre>
When the message is posted, it'll come out looking like this:
Private Sub Calculate_Click(...)
Some more code shows up here...
and some more...
End Sub
EDIT: I forgot, don't retype the code you have in your posts. Always Copy and Paste it between a couple of <pre> and </pre> tags or a couple of <code> and </code> tags.
RageInTheMachine9532
|
|
|
|
|
ok,
I finally got it to work. This is just a question regarding the number of days (not on the code itself). I can't copy and paste, I am working on two computers at once. My question is if you put on the arrival as Thursday and the checkout as Sunday wouldn't the number of days be 3? Thursday night, friday night and sat. night. When i run the program it says two days. If I need to write my code just let me know, it will not be a problem.
Thanks again for giving me all of the suggestions - learning alot.
Thank you,
ibok23
|
|
|
|
|
DateDiff is apparently giving you the number of days between the two dates, not inclusive of the actual days that the dates fall on. If you pick Thursday and the very next Friday, DateDiff(Day) will will return 0. If you pick Thursday and Saturday, it will return 1.
The solution is to just add 1 to whatever DateDiff returns.
RageInTheMachine9532
|
|
|
|
|
If your using VB.Net there is also the System.Timespan Namespace.
You could try something like:
<br />
Dim d1 As DateTime = DateTime.Now<br />
Dim d2 As DateTime = d1.AddMonths(2)<br />
<br />
Dim ts As System.TimeSpan = d2.Subtract(d1)<br />
Dim sDays As String = ts.Days.ToString()<br />
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
LearnVisualStudio.Net
|
|
|
|
|
Cool, that did work.
Thanks again. I maybe calling again on my next project.
Thank you,
ibok23
|
|
|
|
|
Hi,
I'm having a bit of a brainteaser.
What I have:
A typed SQLDataTable with 2 columns with some GUID's and decimal values which represents percentages. I need them to be decimal for the obvious calculations.
What I want:
- Show the values in a ComboBox
- Format them using the local Percentage formatting (difference between 0.1 and 0,1 in most European countries) as you do to format strings with FormatPercent(...)
What I do:
cboPercent.DataSource = DataSetSomething.SQLDataTablePercent
cboPercent.ValueMember = "PercentID"
cboPercent.DisplayMember = "Percent"
The problem:
The ComboBox shows something like 0.2100 instead of 21.00 % or 21,00 %
I don't really know where or how to implement the formatting.
Any help is welcome
Karsten Habay
Belgium
|
|
|
|
|
I have been searching for hours and can't seem to find the answer to this, so maybe it doesn't exist. However, I'll give it a try.
I want to read the audio tracks on a CD. I know how to write data to a .wav format, but can't figure out how to read the data on the CD. I'm sure I can play the audio and write it to a wave file, but this would be done it real-time and would thus be a little on the slow side. Any help would be greatly appreciated.
Thanks!
|
|
|
|
|
You might want to check into someone elses source first before you decide to even attept this. You won't find any examples written in VB or VB.NET for a reason...
Check out the source for CDex on SorceForge: http://sourceforge.net/projects/cdexos/[^]
RageInTheMachine9532
|
|
|
|
|
Now I feel like a total idiot. I can't find source code anywhere.
If I have to go with an external program, I'd like one with a command line interface so I can just call it from inside my code. I'm just trying to write a program to do a very specifice task with audio files.
|
|
|
|
|
Click on the "Browse CVS" link at the bottom of the page.
Also, you might want to download the 1.5.1 release. The .zip file doesn't have to source files in it, but it does have .DLL's that you might be able to use to rip tracks and encode them.
RageInTheMachine9532
|
|
|
|
|
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
|
|
|
|