Date dialog

Mahares

Expert
Licensed User
Longtime User
Erel, Klaus and NJDude may ask you to put your code in IDE format. It will look a lot better for forum users to read it and spot problems. Here is how to do it:
1. Insert all your code in the message form.
2. Highlight all the code and then click on the # sign in the tool bar above to wrap tags around the code.
3. Click on 'Preview post' next to the 'Submit' reply', so you can see it in IDE code format before you send it. It wil look a lot better. It took me a while to find out about that feature.
 
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
OK, let me try this again and make it a little clearer. I can put up a dialog box and it'll display today's date and day of week using code below. What I am needing is how to I get the date from saving the dialog box? So i bring up the dialog box and change it to jan 1, 2000. Where are the variables for it and how do I display it

'---------------------------------------------
'Date dialog box (used on 1700)

Dim Bmp As Bitmap

Dim Dd As DateDialog
Dim Day As String
Dim DayNum As Int

Bmp.Initialize(File.DirAssets, "chips-15.png")
Dim LabelDate As Label 'on panel 1701

B4X:
Sub ButtonAddDate_Click
'---------------------------------------------
'show date dialog box in pop up box.
   
   Dd.Year = DateTime.GetYear(DateTime.Now)
   Dd.Month = DateTime.GetMonth(DateTime.Now)   
   Dd.DayOfMonth = DateTime.GetDayOfMonth(DateTime.Now)
   
   DayNum = DateTime.GetDayOfWeek(Dd.DateTicks)
      If DayNum = 1 Then
         Day = "Sunday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year
      End If
      If DayNum = 2 Then
         Day = "Monday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year 
      End If
      If DayNum = 3 Then
         Day = "Tuesday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year
      End If
      If DayNum = 4 Then
         Day = "Wednesday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year
      End If
      If DayNum = 5 Then
         Day = "Thursday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year
      End If
      If DayNum = 6 Then
         Day = "Friday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year
      End If
      If DayNum = 7 Then
         Day = "Saturday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year
      End If
      
   Dd.Show(Day, "Start of Workday?", "Save", "Cancel", "", Bmp)
   
'---------------------------------------------
'Show Day and date on top line "date to be recorded"   
   LabelDate.text = Day
   
End Sub
 
Last edited:
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
ok, i figured it out. here is code
B4X:
Sub ButtonAddDate_Click
'---------------------------------------------
'show date dialog box in pop up box.
   Dd.Year = DateTime.GetYear(DateTime.Now)
   Dd.Month = DateTime.GetMonth(DateTime.Now)   
   Dd.DayOfMonth = DateTime.GetDayOfMonth(DateTime.Now)
   
   DayNum = DateTime.GetDayOfWeek(Dd.DateTicks)
   
   Select DayNum
         Case 1
            Day = "Right Now, it is Sunday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year
         Case 2
            Day = "Right Now, it is Monday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year
         Case 3
            Day = "Right Now, it is Tuesday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year
         Case 4
            Day = "Right Now, it is Wednesday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year
         Case 5
            Day = "Right Now, it is Thursday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year
         Case 6
            Day = "Right Now, it is Friday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year
         Case 7
            Day = "Right Now, it is Saturday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year
      End Select
   
      
   ret = Dd.Show(Day, "Start of Workday?", "Save", "Cancel", "", Bmp)
   
'-----------------------------------------------------------------------
'change top line with new day and date
   DayNum = DateTime.GetDayOfWeek(Dd.DateTicks)
   
   Select DayNum
         Case 1
            LabelDate.text = ("Sunday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year)
         Case 2
            LabelDate.text = ("Monday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year)
         Case 3
            LabelDate.text = ("Tuesday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year)
         Case 4
            LabelDate.text = ("Wednesday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year)
         Case 5
            LabelDate.text = ("Thursday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year)
         Case 6
            LabelDate.text = ("Friday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year)
         Case 7
            LabelDate.text = ("Saturday: " & Dd.Month & "/" & Dd.DayOfMonth & "/" & Dd.Year)
      End Select
   
End Sub
 
Upvote 0

alfcen

Well-Known Member
Licensed User
Longtime User
Not sure what you are trying to achieve, but I recommend to take advantage of "DateTime.Format", in order to keep your code short, such as:

DateTime.DateFormat = "EEEE: MM/dd/yyyy"
Dd.DateTicks = DateTime.Now

B4X:
Sub ButtonAddDate_Click
   Dd.Show(DateTime.Date(Dd.DateTicks), "Start of Workday?", "Save", "Cancel", "", Bmp)
   'Day = DateTime.Date(Dd.DateTicks)
   LabelDate.Text = DateTime.Date(Dd.DateTicks)
End Sub

Of course you may wish or need to store DateTime.Date(Dd.DateTicks) in your string named 'Day'.
 
Upvote 0
Top