| |

VerySource

 Forgot password?
 Register
Search
View: 2336|Reply: 12

Ask the master how to convert text-type "3 minutes 23 seconds" into 203 seconds!

[Copy link]

1

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-3 18:00:01
| Show all posts |Read mode
Title, etc.
Reply

Use magic Report

0

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 Invalid IP Address

Post time: 2020-1-3 22:12:02
| Show all posts
How to convert text type "3 minutes 23 seconds" into 203 seconds
text1.text = 3 minutes text2.text = 23 seconds
 prviate sub command1 click
  text3.text = val (text1.text) * 60 + text2.text
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-4 00:15:01
| Show all posts
Debug.Print DateDiff ("s", "00:00:00", "00: 3: 23")
Reply

Use magic Report

0

Threads

9

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-4 01:18:01
| Show all posts
TimeSerial function
Reply

Use magic Report

1

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-4 06:03:01
| Show all posts
Forgot to say that this kind of data is many and different in length, for example:
10 minutes and 2 seconds
12 minutes 45 seconds
1 minute and 2 seconds
1 minute 23 seconds
7 seconds ---- no "minutes"
48 seconds

  My initial thoughts were:
 1. Use the len function to obtain the length.
   Use SEARCH ("minute", str, 1) to determine whether the number of digits before "minute" is 1 or 2 digits, and then use mid () to take out
 2.len is less than 4, the string has no "minute", use search ("second", str, 1) to determine the number of digits, and then use mid () to take out
 It's complicated, I don't know if there is a better way!
Reply

Use magic Report

0

Threads

34

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2020-1-4 06:39:01
| Show all posts
Debug.Print DateDiff ("s", "00:00:00", "3 minutes 23 seconds")
Returns 203
Debug.Print DateDiff ("s", "00:00:00", "8:15:49")
Returns 29749
Reply

Use magic Report

0

Threads

34

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2020-1-4 06:45:01
| Show all posts
Debug.Print DateDiff ("s", "00:00:00", "7 seconds")
Returns 7
Reply

Use magic Report

0

Threads

34

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2020-1-4 07:21:01
| Show all posts
// My initial thoughts are:
Although your idea can be realized, it is too tedious.
It is convenient to use ready-made functions
Reply

Use magic Report

1

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-4 08:51:01
| Show all posts
But I use it in EXCEL, I tried it just now, no, the function is undefined!
Reply

Use magic Report

1

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-4 09:18:01
| Show all posts
Solved now, thanks! ~
It is convenient to use ready-made functions!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list