Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ VBscript
➜ string to variable conversion
string to variable conversion
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| ErockMahan
(81 posts) Bio
|
Date
| Thu 20 Feb 2014 04:05 PM (UTC) Amended on Thu 20 Feb 2014 07:56 PM (UTC) by ErockMahan
|
Message
| I've got a bit of a mess here that I'm trying to clean up. I have a variable with numbers put in to in a random order, separated by a space:
numstring = "23 5 187 13"
I want to sort it, so I am using this:
bits = Split(numstring, " ")
for a = UBound(bits) - 1 To 0 Step -1
for j=0 to a
if bits(j)>bits(j+1) then
temp=bits(j+1)
bits(j+1)=bits(j)
bits(j)=temp
end if
next
next
The PROBLEM I have is that this isn't sorting it numerically, it looks like it is sorting it alphabetically. That means that the end result is this:
5 23 187 13
Is there any way I can do this? | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sat 22 Feb 2014 03:36 AM (UTC) |
Message
| For the comparison I suggest you convert to numbers (I don't remember how to do this) instead of comparing strings. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
12,127 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top