|
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
|
|
|
|
|
ibok23 wrote:
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
No. If you don't need 'em, don't put 'em in.
ibok23 wrote:
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)
You have to supply the code that gets the dates from the date picker's and puts them in variables to use in this calculation.
RageInTheMachine9532
|
|
|
|
|
This is what I wrote, it still doesn't work but maybe I am close.
numberofdays.text = datediff(dateinterval.day, dtparrival, dtpcheckout)
dtparrival is my date picker for arrival
dtpcheckout is my date picker for checkout
numberofdays.text shows how many days they are there.
What am i doing wrong?
Thank you,
ibok23
|
|
|
|
|
ibok23 wrote:
numberofdays.text = datediff(dateinterval.day, dtparrival, dtpcheckout)
You're about half way there. The last two parameters you passed in are the references for the DateTimePicker controls themselves, not their values. Make the following change to get at the Value's in your controls:
numberofdays.Text = DateDiff(DateInterval.Day, dtparrival.Value, dtpcheckout.Value)
RageInTheMachine9532
|
|
|
|
|
ooookkkk,
I see.
I am still working on the currency part and then I'll debug it to see if it works. Hopefully. One more question if you don't mind.
numberofdays.text = (will be a number, correct)
ok what if I need to charge somebody $5.00 for every number of days
I wrote this and it didn't work
dim rollawaybed as double = 5
rollawaybedcharge.text = (rollawaybed * numberofdays.text)
then I have to put about the currency, but I am getting that this will not work.
Thank you,
ibok23
|
|
|
|
|
ibok23 wrote:
dim rollawaybed as double = 5
rollawaybedcharge.text = (rollawaybed * numberofdays.text)
Well, you're trying to multiply a Double (number) by a String (.Text). You can't do that. But what you can do is convert the String TO a number first:
Dim rollawaybed As Double = 5
Dim newcharge As Double = rollawaybed * Val(numberofdays.Text)
rollawaybedcharge.Text = Format(newcharge, "C")
Val will convert a string of numbers, like 5 or 5000 (NO PUNCTUATION!), into a actual value that can be used in calculations.
RageInTheMachine9532
|
|
|
|
|
I would like to have a datagrid that automatically 'Refreshes' the dataset every time a new record is entered into the sql database. When I run the update on the dataset, fill the datagrid and use the expand statement, it does not fill out the rows.
Any help / suggestions to achieving this is appreciated.
Thanks!
Bob Gronenthal
|
|
|
|
|
Can you show us your code piece ?
-----------------------------------------------------------
"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
|
|
|
|
|
This is the code as it stands right now...
'Updates the current dataset the datagrid is using
Me.SqlDAFire_Cur.Update(Me.DsFire_Cur1)
Me.SqlDAFire_Cur.Fill(Me.DsFire_Cur1)
'Rebind the datasource to the datagrid
Me.DataGridFire.DataSource = Nothing
Me.DataGridFire.DataSource = Me.DsFire_Cur1
Me.DataGridFire.Expand(-1)
It does not expand the entire datagrid with the records though and since I would like this automated I was thinking of putting this into a timer event.
Thanks,
Bob
|
|
|
|
|
Anybody know how to convert a colour picked from a colour picker or whatever into an HTML colour code?
Much Obliged!
|
|
|
|
|
colors are represented in long
so try this (VB6)
htmlColor = "#" & Hex(Color)
|
|
|
|
|
Would that work in .NET also? Thanks for the help.
|
|
|
|
|
I am having a problem while setting the startup object to sub-main,
even though inside the sub main i have loaded two forms that have their own
things to do,
to programs ends at the end of sub main,
so how do i keep it alive?
- Note: using a modal form (myForm.ShowDialog) is not an option as my project needs to switch focus between forms.
Fade (Amit BS)
|
|
|
|
|
Loading and showing two forms will not keep your app open. Since your sub Main ends, so does your app. Really, what you should be doing is starting your app with a Form, since the message pump in this form will not end, and therefore your app, until the pump recieves a WM_QUIT message.
What is the purpose of having a Sub Main in your app?
RageInTheMachine9532
|
|
|
|
|
Well, i know that using a form as a startup object will keep it alive,
the main reason to use a 'Sub Main' is to get command line arguments, and i find it more organized to create an instance of the main form through code.
So a. commandline arguments
and b. neet code.
any suggestions?
Fade (Amit BS)
|
|
|
|
|
Fade (Amit BS) wrote:
a. commandline attributes
You don't need a Sub Main for command line arguments.
In you Form_Load event, or something else close to your app starting up, just use Environment.GetCommandLineArgs() to get a String array of the arguments.
Fade (Amit BS) wrote:
b. neet code
But a pain in the butt to keep an app running. It's MUCH easier to just have a main form and have that form launch the others than it is to keep a Sub Main in a relatively infinite loop watching for and waiting for all the open forms, most of which it has no clue even exist, to be closed and unloaded.
Think about it. Pick any app in Windows, like Word, VS.NET... They all have a main form and a bunch of helper forms that the main form launches and manages.
RageInTheMachine9532
|
|
|
|
|
ok,
You win
the command line arguments solution has tilted it to your favour, especially when there is no easy 'right' way to keep the app running via sub main.
thanx, i'll go back to using a main form.
Fade (Amit BS)
|
|
|
|
|
Hi im trying to retrieve data using a listview but get the following error when running:
An unhandled exception of type 'System.Data.SqlTypes.SqlNullValueException' occurred in system.data.dll
Additional information: Data is Null. This method or property cannot be called on Null values.
My code is as follows:
listitems.subItems.Add(IIf(IsDBNull(.GetString(1)), .GetString(1), ""))
can someone please help
Chrissy Callen
|
|
|
|
|
Chrissy Callen wrote:
listitems.subItems.Add(IIf(IsDBNull(.GetString(1)), .GetString(1), ""))
This statement is sitting inside a 'With' block. It would help to know what that 'With' is.
The GetString Method is being executed on a record that doesn't have a value. What you should be checking for first is if there is a value there, then execute GetString on it. Your trying to see if GetString returns a NULL, and if true, return the GetString NULL, if false, return an Empty string.
What you should be doing is this:
IIF( expression, Object if expression True, Object if expression False ) As Object
listitems.subItems.Add( IIf( IsDBNull(<whatever'With'Is>), "", .GetString(1) ) )
RageInTheMachine9532
|
|
|
|
|
It has to do with the IIf statement. It evaluates both conditions, regardless of whether the first one is true or not. In other words, it does not short-circuit. You need to use the regular VB If-Else-End If construct to make this logic work the way you want.
|
|
|
|
|
Hi
First sorry because my english is not very good.
I am a vb.net beginner , later I work with Visual C++.May be my problem is funny or maybe the datagrid is not a standard tool to work with data(add,remove,update,...) but I really have lots of problem with it.
I want to design a form that user should enter many records and at a time see the previous and next records.This Table has many fields I think it must be easier for the user to enter some of the fields in the columns of the datagrid and some of it in the form(textbox,combo,..) below the datagrid. and also some of the datagrid should be like combo box and some of it textbox and some of it Timeformat.I can connect the datagrid to the base and read the data . but I have not any control on the DataGrid,for example set a special query or change the column appearance to combo box or Mask edit or tabbed from one row of the column to the fields of the form for entering another fields of the record.how can I do these?
Can I use Ado not ado.net with VB.Net dataGrid ? if I can use ado and set the columns of the datagrid to the ado recordset it's so better.if I can do it please tell me how?Thanks a lot
|
|
|
|