|
-
Apr 4th, 2008, 11:00 AM
#1
Thread Starter
Lively Member
[RESOLVED] calculating dates
Dear Friends,
i am using Vb 6
and i have 2 text box on a form and both are dates
and the code is :
Code:
Public date1 As Date
Public date2 As Date
Private Sub Form_Load()
Text1.Text = Format(Date, "dd-mmm-yy")
Text2.Text = Format(Date + 2, "dd-mmm-yy")
End Sub
Private Sub Text1_LostFocus()
date2 = Format(date1, "dd-mmm-yy") + 2
Text2.Text = date2
End Sub
actully what i want is, that IF Text1Box change the date Text2Box should add 1 day into it!
thanks
-
Apr 4th, 2008, 11:06 AM
#2
Re: calculating dates
Convert the date in Text1 by using the CDate function (i.e., date2=CDate(Text1.Text). Then add 2 to that. Note: CDate will fail if the data in text1 is not a valid date format.
-
Apr 4th, 2008, 11:35 AM
#3
Re: calculating dates
Use a datepicker control instead of a textbox
-
Apr 4th, 2008, 12:13 PM
#4
Thread Starter
Lively Member
Re: calculating dates
thanks
how?? datepicker
can u pls upload any sample file?
regards,
-
Apr 4th, 2008, 12:16 PM
#5
Re: calculating dates
 Originally Posted by skaswani
actully what i want is, that IF Text1Box change the date Text2Box should add 1 day into it!
thanks
This is one way of doing it...
vb Code:
Private Sub Text1_AfterUpdate()
Dim TEMP As String
TEMP = Format(Text1.Text, "dd-mmm-yy")
Text2.Text = Format((Val(Left(TEMP, 2)) + 1), "00") & Mid(TEMP, 3, Len(TEMP) - 2)
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Apr 4th, 2008, 12:34 PM
#6
Thread Starter
Lively Member
Re: calculating dates
thank you dears
but i think its really better to use date picker..
can anyone upload sample file
thanks
-
Apr 4th, 2008, 01:01 PM
#7
Re: calculating dates
They are simple, you shouldn't need a sample file - you should be able to do what you need from the article What controls can I use to input a date/time? from our Classic VB FAQs (in the FAQ forum, which is shown near the top of our home page)
-
Apr 4th, 2008, 01:10 PM
#8
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|