![]() |
NEED HELP: For this Code
Dear Friends,
See below my code and it is not coming as desired. Kindly resolve this please. Private Sub UserForm_Activate() Dim Wish As String Dim Cur_Time As Date Dim Cur_User As String Cur_Time = Time 'Label1.Caption = Cur_Time If Cur_Time = "12:00:00AM" And Cur_Time < "12:00:00PM" Then Wish = "Good Morning" ElseIf Cur_Time = "12:00:00PM" And Cur_Time < "3:00:00PM" Then Wish = "Good Afternoon" ElseIf Cur_Time = "3:00:00PM" And Cur_Time < "12:00:00AM" Then Wish = "Good Evening" Else: Wish = "NULL" End If Label1.Caption = Cur_Time & " - " & Wish End Sub It displays the current time with Wish data as NULL. Kindly let me know about the mistake I did. Thanks and Regards, Sriram Subramaniyan |
NEED HELP: For this Code
add spaces before the AM and PM Private Sub UserForm_Activate() Dim Wish As String Dim Cur_Time As Date Dim Cur_User As String Cur_Time = Time 'Label1.Caption = Cur_Time If Cur_Time = "12:00:00 AM" And Cur_Time < "12:00:00 PM" Then Wish = "Good Morning" ElseIf Cur_Time = "12:00:00 PM" And Cur_Time < "3:00:00 PM" Then Wish = "Good Afternoon" ElseIf Cur_Time = "3:00:00 PM" And Cur_Time < "12:00:00 AM" Then Wish = "Good Evening" Else: Wish = "NULL" End If Label1.Caption = Cur_Time & " - " & Wish End Sub -- Bearacade ------------------------------------------------------------------------ Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016 View this thread: http://www.excelforum.com/showthread...hreadid=552740 |
All times are GMT +1. The time now is 04:21 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com