Micro Focus QTP (UFT) Forums
problems with formatting text - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: problems with formatting text (/Thread-problems-with-formatting-text)



problems with formatting text - bis - 07-15-2008

i have a text box i want to put the time and date in so i can keep track of the times the tests are run
Code:
SwfWindow("Form").SwfEdit("TextboxName").Set "time " & Time()

the problem is i want to format the time a certain way so i wrote this function
Code:
Function formatmyTime
Dim myTime
FormatDateTime Now(), 3
myTime = "Time = " & Month(Now()) & "." & Day(Now()) & "." & Year(Now()) & " " & Time()
myTime = Replace(myTime,":",".")
End Function
myTime should now be 7.15.2008 9.25.57 AM
now how do i make it call myTime
Code:
SwfWindow("Form").SwfEdit("TextboxName").Set "time " & Time()
the reason is that it creates so many records in the database i wanted to add the seconds to them i can search the database easier. and the reason i have to format it is because my textbox does not allow the : character


RE: problems with formatting text - Ankur - 07-16-2008

you need to do a small change in code:

Code:
Function formatmyTime
Dim myTime
FormatDateTime Now(), 3
myTime = "Time = " & Month(Now()) & "." & Day(Now()) & "." & Year(Now()) & " " & Time()
formatmyTime = Replace(myTime,":",".")
End Function

Code:
SwfWindow("Form").SwfEdit("TextboxName").Set "formatmyTime"