(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
06-13-24 04:39 AM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - VB6 Halving strings New poll | |
Add to favorites | Next newer thread | Next older thread
User Post
Arthus

140


 





Since: 11-17-05
From: Australia

Last post: 6536 days
Last view: 6536 days
Posted on 03-19-06 11:50 AM Link | Quote
I can't seem to locate a function that can let me half a string. When I tried to make one, I couldn't find anything that would remotly help me in doing so. So does anyone have a function that would let me turn a string into an array.

Example:
String = "AE"

after putting this string through the function:
hlaf("AE")

the array would come as follows:
results = Array(
1 => "A"
2 => "E"
)

Or something along those lines.
dcahrakos

490


 





Since: 11-17-05

Last post: 6541 days
Last view: 6541 days
Posted on 03-19-06 04:02 PM Link | Quote
I know you can use the split function to split strings into an array, but im not sure if you can use split to actually half the string without some delimiter, such as a space, or any other letter or symbol right at the halfway point of the string...so if you did want it like that you could do:

dim arry() as string
arry = Split (strng, " "), but that will split the string at every space, you can change the delimiter to whatever, but I dont think split can do halves, ill look for a specific function for you though.
Dan

Purple Leever


 





Since: 11-18-05

Last post: 6333 days
Last view: 6324 days
Posted on 03-19-06 06:00 PM Link | Quote
The functions you are looking for are the Left function, the Right function, and probably also the Len function.

I'd actually forgotten how poor VB's string support actually is.
Parasyte +

Red Paragoomba


 





Since: 01-05-06

Last post: 6645 days
Last view: 6645 days
Posted on 03-19-06 06:13 PM Link | Quote
If this is for splitting hexadecimal bytes into nybbles, as it appears to be, you are better off using math:

results(1) = number / 16
results(2) = number Mod 16
Kyoufu Kawa
Intends to keep Rom Hacking in one piece until the end








Since: 11-18-05
From: Catgirl Central Station

Last post: 6324 days
Last view: 6324 days
Posted on 03-20-06 02:54 PM Link | Quote
...but either way, to split using VB6's indeed (and I too think they could be better), use...

firstHalf = Left(fullString, Len(fullString) / 2)
secondHalf = Right(fullString, Len(fullString / 2)

Might need a +1 or -1 somewhere.
Sukasa

Birdo
Not quite as active as before.
Xkeeper supporter
Xk > ||bass
I IP Banned myself! Twice!








Since: 11-17-05
From: Somewhere over there

Last post: 6325 days
Last view: 6324 days
Posted on 03-27-06 06:57 PM Link | Quote
Here, I placed kawa's code into a function for you to use.


Public Function Halve(input As String)
' This function returns a string array. to use, dimension a dynamic string array, i.e.
' Aim array() as string.
' Then
' array = Halve("string")

' This will return array(0) = "str", array(1) = "ing".


' Declare variables
dim internalarray(1) As String, internala as integer

' Find missle point.
internala = (Len(input) - (Len(input) Mod 2)) / 2

' Split the input string
internalarray(0) = left(input, internala)
internalarray(1) = Right(input, Len(input) - internala)

' And return the new data.
Halve = internalarray
End Function


That should work for you.
Add to favorites | Next newer thread | Next older thread
Acmlm's Board - I3 Archive - Programming - VB6 Halving strings |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.009 seconds; used 374.91 kB (max 453.52 kB)