Click here to Skip to main content
15,667,422 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

I am new in VbScript, I have an assignment where I have to get the latest value in the timestamp using VbScript..
this is how it looks:

Value | Timestamp
0 | 06.06.2022 00:00:12
2 | 06.06.2022 00:10:00
0 | 06.06.2022 00:11:00
12| 06.06.2022 00:12:12
100 | 06.06.2022 00:12:50
Null/empty | 06.06.2022 00:13:50
Null/empty | 06.06.2022 00:13:51
Null/empty | 06.06.2022 00:13:52
Null/empty | 06.06.2022 00:13:53

I would like to have the latest value that was recorded. The 100.

Your help is much appriciated.

What I have tried:

I tried to do some research but could not find anything in particlar related to "lastValue"
Updated 6-Jun-22 23:48pm
Richard MacCutchan 7-Jun-22 3:11am    
Read the data (from wherever it is stored) item by item. Extract the timestamp field and convert it to a DateTime object, and add it to a list. It is then a simple matter to find the largest item in a list.
Member 13410460 7-Jun-22 3:21am    
Thank you for your reply, I also thought of that but that will bring the "biggest" value, I need the latst value, it could happen that the latest value wont be "bigger" then the rest..
Richard MacCutchan 7-Jun-22 3:32am    
Yes it will, since a DateTime value is a simple number of milliseconds since a fixed time in the past.
Member 13410460 7-Jun-22 3:36am    
hmm actually you are right, I check where is the "bigger" date which has the value and take that value and use it..
That is genius. Please write it as a solution so I can make it as "answered" :)
Richard MacCutchan 7-Jun-22 3:37am    
It's not really enough to be a solution. Just add "[Solved]" to the title of your question.

1 solution

Since you have asked 23 question over the last two years, you are well aware that while we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900