Skip to main content

Good morning everyone,

So I have quite a few scripts that depend on the formatting command to format the date to how I need it.

Since the months have changed from a single digit, to a double digit, I am starting to run into some issues.

 

First off, here is my Format command:

Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

 

So here is my problem,

I have my scripts set to read the screen for the date, I originally had it set for 7 characters since it was 9/xx/xx but now since it's 10/xx/xx I'm having to go back and adjust each line to 8 that refers to that date.

Also, positioning, I have it currently set for EMReadScreen X,X,63 and am having to change all those to EMReadScreen X,X,62 since I need it to read that extra digit.

 

Is there anyway around this? Am I using the correct command for this situation?

Here is an example I am using.

D = Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

For i = 9 to 19
EMReadScreen MyString, 8, i, 63
If UCase(MyString) = D then
EMSetCursor i, 4
EMWaitX 1, RetC
EMSendKey "1"
EMWaitX 1, RetC
Exit for
Else
End if
Next i

 

 

As always, thanks in advance.


#Rumba

Good morning everyone,

So I have quite a few scripts that depend on the formatting command to format the date to how I need it.

Since the months have changed from a single digit, to a double digit, I am starting to run into some issues.

 

First off, here is my Format command:

Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

 

So here is my problem,

I have my scripts set to read the screen for the date, I originally had it set for 7 characters since it was 9/xx/xx but now since it's 10/xx/xx I'm having to go back and adjust each line to 8 that refers to that date.

Also, positioning, I have it currently set for EMReadScreen X,X,63 and am having to change all those to EMReadScreen X,X,62 since I need it to read that extra digit.

 

Is there anyway around this? Am I using the correct command for this situation?

Here is an example I am using.

D = Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

For i = 9 to 19
EMReadScreen MyString, 8, i, 63
If UCase(MyString) = D then
EMSetCursor i, 4
EMWaitX 1, RetC
EMSendKey "1"
EMWaitX 1, RetC
Exit for
Else
End if
Next i

 

 

As always, thanks in advance.


#Rumba

Hi Erik,

A screen shot of how those data appear on screen would be nice.
How to the appear? I'm guessing that if the day or month start are < 10 the the first charact appears as a space,

e.g.
from col 62 you see
                   " 1/ 1/18"      for Jan 1st 2018
                   "10/ 1/18"      for Oct 1st 2018
                   " 1/10/18"      for Jan 10th 2018
                   "10/10/18"      for Oct 10th 2018

So basically if the month of day is < 10, then the first character in that portion is a space, i.e. " "

After each EMReadScreen could substitute this " " for a "0" in a couple of if loops

e.g.
If Left(MyString, 1) = " " then MyString = 0 & Right(MyString, 7)
If Mid(MyString, 4, 1) = " " then MyString = Left(MyString, 3) & "0" & Right(MyString, 4)

Naturally a lot depends on how the Dates appear on the terminal screen, can you provide a partial screenshot?

Tom
 


Good morning everyone,

So I have quite a few scripts that depend on the formatting command to format the date to how I need it.

Since the months have changed from a single digit, to a double digit, I am starting to run into some issues.

 

First off, here is my Format command:

Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

 

So here is my problem,

I have my scripts set to read the screen for the date, I originally had it set for 7 characters since it was 9/xx/xx but now since it's 10/xx/xx I'm having to go back and adjust each line to 8 that refers to that date.

Also, positioning, I have it currently set for EMReadScreen X,X,63 and am having to change all those to EMReadScreen X,X,62 since I need it to read that extra digit.

 

Is there anyway around this? Am I using the correct command for this situation?

Here is an example I am using.

D = Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

For i = 9 to 19
EMReadScreen MyString, 8, i, 63
If UCase(MyString) = D then
EMSetCursor i, 4
EMWaitX 1, RetC
EMSendKey "1"
EMWaitX 1, RetC
Exit for
Else
End if
Next i

 

 

As always, thanks in advance.


#Rumba

Yes Sorry about that Tom. I have attached a screen shot for reference.

But yes you are correct, there is a space before them, no 0's in this case. 

I am not familiar with Left, Mid, and Right, so I will need to investigate how to use those a bit more if that's the case.

 

 


Good morning everyone,

So I have quite a few scripts that depend on the formatting command to format the date to how I need it.

Since the months have changed from a single digit, to a double digit, I am starting to run into some issues.

 

First off, here is my Format command:

Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

 

So here is my problem,

I have my scripts set to read the screen for the date, I originally had it set for 7 characters since it was 9/xx/xx but now since it's 10/xx/xx I'm having to go back and adjust each line to 8 that refers to that date.

Also, positioning, I have it currently set for EMReadScreen X,X,63 and am having to change all those to EMReadScreen X,X,62 since I need it to read that extra digit.

 

Is there anyway around this? Am I using the correct command for this situation?

Here is an example I am using.

D = Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

For i = 9 to 19
EMReadScreen MyString, 8, i, 63
If UCase(MyString) = D then
EMSetCursor i, 4
EMWaitX 1, RetC
EMSendKey "1"
EMWaitX 1, RetC
Exit for
Else
End if
Next i

 

 

As always, thanks in advance.


#Rumba
Hi Erik,

OK so all you should need to do is read from Column 62 and use LTrim (left trim) to trim any leading space. So, if the month is < 10, then the leading space will be striped out. If it's 10, 11 or 12, then there will be no leading space.


D = Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

For i = 9 to 19
EMReadScreen MyString, 8, i, 62
MyString = LTrim(MyString)
If UCase(MyString) = D then
EMSetCursor i, 4
EMWaitX 1, RetC
EMSendKey "1"
EMWaitX 1, RetC
Exit for
Else
End if
Next i

Tom

Good morning everyone,

So I have quite a few scripts that depend on the formatting command to format the date to how I need it.

Since the months have changed from a single digit, to a double digit, I am starting to run into some issues.

 

First off, here is my Format command:

Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

 

So here is my problem,

I have my scripts set to read the screen for the date, I originally had it set for 7 characters since it was 9/xx/xx but now since it's 10/xx/xx I'm having to go back and adjust each line to 8 that refers to that date.

Also, positioning, I have it currently set for EMReadScreen X,X,63 and am having to change all those to EMReadScreen X,X,62 since I need it to read that extra digit.

 

Is there anyway around this? Am I using the correct command for this situation?

Here is an example I am using.

D = Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

For i = 9 to 19
EMReadScreen MyString, 8, i, 63
If UCase(MyString) = D then
EMSetCursor i, 4
EMWaitX 1, RetC
EMSendKey "1"
EMWaitX 1, RetC
Exit for
Else
End if
Next i

 

 

As always, thanks in advance.


#Rumba
Yes that is exactly what I was looking for!

Thank you Tom I appreciate it!

Good morning everyone,

So I have quite a few scripts that depend on the formatting command to format the date to how I need it.

Since the months have changed from a single digit, to a double digit, I am starting to run into some issues.

 

First off, here is my Format command:

Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

 

So here is my problem,

I have my scripts set to read the screen for the date, I originally had it set for 7 characters since it was 9/xx/xx but now since it's 10/xx/xx I'm having to go back and adjust each line to 8 that refers to that date.

Also, positioning, I have it currently set for EMReadScreen X,X,63 and am having to change all those to EMReadScreen X,X,62 since I need it to read that extra digit.

 

Is there anyway around this? Am I using the correct command for this situation?

Here is an example I am using.

D = Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

For i = 9 to 19
EMReadScreen MyString, 8, i, 63
If UCase(MyString) = D then
EMSetCursor i, 4
EMWaitX 1, RetC
EMSendKey "1"
EMWaitX 1, RetC
Exit for
Else
End if
Next i

 

 

As always, thanks in advance.


#Rumba
Hello Tom,

I ran into another issue today that is related to this issue, so I thought i'd just reply here.

When I run certain reports they need to refer to previous days and this has worked no problem in the past.
However, i'm not sure if since the months are double digits now, it's acting strange.

For Example:
If I use a command to write a date that was two days ago which is for the end of last month using this:

EMWriteScreen Format(Month(Date), "00") & "/" & Format(day(Date)-2, "00") & "/" & Format(Year(Date), "0000"), 6,22

That will return me 10/00/2018.
I needed it to return 9/30/2018

Any thoughts?

Good morning everyone,

So I have quite a few scripts that depend on the formatting command to format the date to how I need it.

Since the months have changed from a single digit, to a double digit, I am starting to run into some issues.

 

First off, here is my Format command:

Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

 

So here is my problem,

I have my scripts set to read the screen for the date, I originally had it set for 7 characters since it was 9/xx/xx but now since it's 10/xx/xx I'm having to go back and adjust each line to 8 that refers to that date.

Also, positioning, I have it currently set for EMReadScreen X,X,63 and am having to change all those to EMReadScreen X,X,62 since I need it to read that extra digit.

 

Is there anyway around this? Am I using the correct command for this situation?

Here is an example I am using.

D = Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

For i = 9 to 19
EMReadScreen MyString, 8, i, 63
If UCase(MyString) = D then
EMSetCursor i, 4
EMWaitX 1, RetC
EMSendKey "1"
EMWaitX 1, RetC
Exit for
Else
End if
Next i

 

 

As always, thanks in advance.


#Rumba
way too many thoughts Erik :-)

On this particular issue you could try the following..

Sub main
'Set i = to the number of days you want to add to todays date
'To subtract, set i = a negative number
Dim i as Integer
i = -2
Msgbox Format(CDate(CLng(Date) i),"m/dd/yyyy")
End Sub

The CLng(Date) converts todays date to a Julian date, which is basically a long number, the number of days since 12 midday UTC on Jan 1 4713 BC !!!

Then is add the i days to it and then converts the result back into your normal date with the format m/dd/yyyy (with no leading 0 for the month if it's < 10)

Cheers,
Tom

Good morning everyone,

So I have quite a few scripts that depend on the formatting command to format the date to how I need it.

Since the months have changed from a single digit, to a double digit, I am starting to run into some issues.

 

First off, here is my Format command:

Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

 

So here is my problem,

I have my scripts set to read the screen for the date, I originally had it set for 7 characters since it was 9/xx/xx but now since it's 10/xx/xx I'm having to go back and adjust each line to 8 that refers to that date.

Also, positioning, I have it currently set for EMReadScreen X,X,63 and am having to change all those to EMReadScreen X,X,62 since I need it to read that extra digit.

 

Is there anyway around this? Am I using the correct command for this situation?

Here is an example I am using.

D = Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

For i = 9 to 19
EMReadScreen MyString, 8, i, 63
If UCase(MyString) = D then
EMSetCursor i, 4
EMWaitX 1, RetC
EMSendKey "1"
EMWaitX 1, RetC
Exit for
Else
End if
Next i

 

 

As always, thanks in advance.


#Rumba

Wow that is a lot of code just to have it go back to the previous month XD

 

But alright I can definitely make it work.

 

Thanks again Tom!


Good morning everyone,

So I have quite a few scripts that depend on the formatting command to format the date to how I need it.

Since the months have changed from a single digit, to a double digit, I am starting to run into some issues.

 

First off, here is my Format command:

Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

 

So here is my problem,

I have my scripts set to read the screen for the date, I originally had it set for 7 characters since it was 9/xx/xx but now since it's 10/xx/xx I'm having to go back and adjust each line to 8 that refers to that date.

Also, positioning, I have it currently set for EMReadScreen X,X,63 and am having to change all those to EMReadScreen X,X,62 since I need it to read that extra digit.

 

Is there anyway around this? Am I using the correct command for this situation?

Here is an example I am using.

D = Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

For i = 9 to 19
EMReadScreen MyString, 8, i, 63
If UCase(MyString) = D then
EMSetCursor i, 4
EMWaitX 1, RetC
EMSendKey "1"
EMWaitX 1, RetC
Exit for
Else
End if
Next i

 

 

As always, thanks in advance.


#Rumba
Also Tom, there are reports that go back more than 3 days pending on which one I am working, do I need to manually set this for each one? Is there universal command I can put for when it references a day that does not exist in the month to go to the previous month?

Good morning everyone,

So I have quite a few scripts that depend on the formatting command to format the date to how I need it.

Since the months have changed from a single digit, to a double digit, I am starting to run into some issues.

 

First off, here is my Format command:

Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

 

So here is my problem,

I have my scripts set to read the screen for the date, I originally had it set for 7 characters since it was 9/xx/xx but now since it's 10/xx/xx I'm having to go back and adjust each line to 8 that refers to that date.

Also, positioning, I have it currently set for EMReadScreen X,X,63 and am having to change all those to EMReadScreen X,X,62 since I need it to read that extra digit.

 

Is there anyway around this? Am I using the correct command for this situation?

Here is an example I am using.

D = Format(Month(Date), "0") & "/" & Format(day(Date), "00") & "/" & "18"

For i = 9 to 19
EMReadScreen MyString, 8, i, 63
If UCase(MyString) = D then
EMSetCursor i, 4
EMWaitX 1, RetC
EMSendKey "1"
EMWaitX 1, RetC
Exit for
Else
End if
Next i

 

 

As always, thanks in advance.


#Rumba
Hi Eric,

you can create a function to calculate the new date and tell it how many days in the past or the future you wish to calculate.

e.g

Sub Main
Dim myNewDate as String, myOtherNewDate as String
myNewDate = NewDateFromToday(-4)
myOtherNewDate = NewDateFromToday( 32)
Msgbox myNewDate
Msgbox myOtherNewDate
End Sub

Function NewDateFromToday(offset as integer) as String
NewDate$ = Format(CDate(CLng(Date) offset),"m/dd/yyyy")
If Len(NewDate)= 9 then NewDate = " " & NewDate
NewDateFromToday = NewDate
End Function

So in the above sub main, you calculate 2 dates, the first -4 == four days ago, the second 32 days into the future from today.

The If statement in the function prepends a space to the string if the month earlier than October.

Cheers,
Tom