dynamitemedia Posted April 25, 2015 Posted April 25, 2015 i can find how to do the opposite but i want to take 00:00:22.17 and put into milliseconds which would be 22017 ?? or no seems like it should be super simple but not finding it anywhere. i get a bunch of audio files with that time stamp and i and i want to to convert to milliseconds thanks!
water Posted April 25, 2015 Posted April 25, 2015 What have you tried yourself so far? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
mikell Posted April 25, 2015 Posted April 25, 2015 This reminds me something Msgbox(0,"", Convert2ms("00:00:22.17") ) Func Convert2ms($sTime) ;format "HH:MM:SS.ms", no error / validity check for input! Return Execute("'" & StringRegExpReplace($sTime, "(\d+):(\d+):(\d+)\.(\d*)", _ "' & $1*3600*1000+$2*60*1000+$3*1000+$4 & '") & "'") EndFunc dynamitemedia 1
TheSaint Posted April 25, 2015 Posted April 25, 2015 Check out the StringSplit function as one method to get an array, which you will need to do twice. Hours times 60 to get minutes. Minutes times 60 to get seconds. Seconds times 1000 to get milliseconds. We could provide the code easy enough, but I believe in helping those who help themselves, so as water said, provide us with what you have tried so far, or with what I have now given you a clue to, if necessary. We can help fine tune any issues you can't surmount. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
TheSaint Posted April 25, 2015 Posted April 25, 2015 @mikell - I know you are trying to be helpful, but giving a golden platter solution like that to a seeming newbie, is not really teaching them anything. As they say, best to learn to walk before learning to ride. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
mikell Posted April 25, 2015 Posted April 25, 2015 TheSaint, You are obviously right but I couldn't help but posting it BTW I would say lazy instead of newbie
water Posted April 25, 2015 Posted April 25, 2015 It is a quite advanced solution (at least for me as I'm not good with regular expressions). I would have - like TheSaint - suggested to start with StringSplit. TheSaint 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
TheSaint Posted April 25, 2015 Posted April 25, 2015 (edited) TheSaint, You are obviously right but I couldn't help but posting it BTW I would say lazy instead of newbie Nothing wrong with posting it once they had tried and succeeded with an easier method. After all, they won't be a newbie forever and many others will see this topic perhaps, and benefit from an advanced solution. Probably not water and I though, as we tend to avoid RegExp stuff ... so we can sleep at night. Edited April 25, 2015 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
dynamitemedia Posted April 25, 2015 Author Posted April 25, 2015 I was not being lazy if you see all my posts here i show my solutions every time, not to mention i ask to be sent in right direction... this topic was not covered anywhere i could find.i got stuck for hours and wanted to see if anyone had any ideas and when i woke up could work again, no reason to start making assumptions about my laziness etc.I didn't know where to start is why i started the thread. never said hand me over code. thanks mikell that is what i was thinking about b4 i went to bed last night. i wasnt sure it would be that simple i thought i would need to be doing some addition etc...
jguinch Posted April 25, 2015 Posted April 25, 2015 (edited) @Mikell : just a small remark. You can remove your concatenation and juste keep the calculation : Func Convert2ms($sTime) Return Execute(StringRegExpReplace($sTime, "(\d+):(\d+):(\d+)\.(\d*)", "($1*3600+$2*60+$3)*1000+$4") ) EndFunc Edited April 25, 2015 by jguinch dynamitemedia 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
UEZ Posted April 25, 2015 Posted April 25, 2015 Non regex version:Func Convert2ms($sTime) Return StringLeft($sTime, 2) * 3600000 + StringMid($sTime, 4, 2) * 60000 + StringMid($sTime, 7, 2) * 1000 + StringRight($sTime, 2) EndFunc dynamitemedia 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
mikell Posted April 25, 2015 Posted April 25, 2015 jguinch,Thanks for the tip. Less quotes, mmm... lovely UEZ,I remember the former topic, there is one example more using StringSplit
UEZ Posted April 25, 2015 Posted April 25, 2015 Regex is not only for beginners not easy to understand. Further many ways lead to Rome and it is always good to see more ways. czardas 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now