Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / August 2006

Tip: Looking for answers? Try searching our database.

Newbie needs help on date and time controls on form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
M Skabialka - 22 Aug 2006 15:19 GMT
I am trying to create my first Visual Basic program, and placed text fields
on the form which I want to show the date on one and the time on the other.
Under properties I am totally lost as to where to format the information in
the text box as date or time.  I've looked under appearance, font, behavior,
data, databindings, design, layout, location and size, and none show where
the field can be text, a number, date or time, etc.  What incredibly obvious
thing am I missing?  Or did I place the wrong control on the form in the
first place?
Mich
Des - 22 Aug 2006 15:25 GMT
The text box is just for displaying text. you have to format the text
youself.

Desmond

> I am trying to create my first Visual Basic program, and placed text fields
> on the form which I want to show the date on one and the time on the other.
[quoted text clipped - 5 lines]
> first place?
> Mich
M Skabialka - 22 Aug 2006 15:32 GMT
How?
Format(Now(), "mm,dd,yyyy")
Doesn't work

> The text box is just for displaying text. you have to format the text
> youself.
[quoted text clipped - 16 lines]
>> first place?
>> Mich
Des - 22 Aug 2006 15:39 GMT
Dim d As Date
Dim s As String
d = Now()
s = Format(d, "ddd dd mmm yyyy")

Check out the Format function

Desmond.

> How?
> Format(Now(), "mm,dd,yyyy")
[quoted text clipped - 20 lines]
> >> first place?
> >> Mich
M Skabialka - 22 Aug 2006 16:06 GMT
Maybe I should try to explain what I want to do as my first project:

I am creating a simple form with three labels and three text boxes.  The
first label and box are for the start time, the second for the end time, the
third for the difference.  I thought this would be a really easy first
project - I press the first button and the time is set on the first box.
When I press the second button the end time shows in the second box.  At
that time it calculates the time difference in minutes, so that I can time
the number of minutes I work on something.
Using your code I get an error on the last line:
Dim d As Date
Dim s As String
d = Now()
s = Format(d, "ddd dd mmm yyyy")
txtStartTime = s    'txtStartTime is the name of my text box

The 's' is highlighted and the error is:
Value of type 'string'cannot be converted to 'System.Windows.Forms.TextBox'

I am sure there is a similar function for time as there is for date.  There
must be a very simple solution to this.
Thanks,
Mich

> Dim d As Date
> Dim s As String
[quoted text clipped - 31 lines]
>> >> first place?
>> >> Mich
dotnetman - 24 Aug 2006 15:39 GMT
<snip>
> Using your code I get an error on the last line:
> Dim d As Date
[quoted text clipped - 11 lines]
> Thanks,
> Mich

I don't use VB, but I am sure you cannot set the TextBox control to a string
value. You need to use the Text property of the TextBox.

Try using this:

Dim d As Date
Dim s As String
d = Now()
s = Format(d, "ddd dd mmm yyyy")
txtStartTime.Text  = s

Look at the Examples and HowTos in the VB help.

Regards
<snip>

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.