Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-23-2012, 09:03 AM
tinfanide tinfanide is offline Convert String Array to Integer Array from a User Input? Windows 7 64bit Convert String Array to Integer Array from a User Input? Office 2010 32bit
Expert
Convert String Array to Integer Array from a User Input?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default Convert String Array to Integer Array from a User Input?


Code:
Sub q()

Dim vInput As Variant
vInput = InputBox("", "", "9,1,3,5,6,2,4,10,7,8")

Dim arr As Variant, a As Variant
arr = Split(vInput, ",")

Debug.Print TypeName(arr) '' String()

For a = LBound(arr) To UBound(arr)
    arr(a) = CInt(arr(a)) '' to convert string to integer
    Debug.Print TypeName(arr(a)) '' String
Next a

End Sub
This is a general VBA question.
I ask it here. I code the above in Word though.

I want to use CInt() to convert each item in an array from string to integer but it fails.
How can I convert a string array to an integer array?

Thank you.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Array argument in macro command Wries Excel Programming 2 11-20-2012 01:08 AM
How to reserve an array in a public function? tinfanide Word VBA 2 02-27-2012 06:51 AM
Convert String Array to Integer Array from a User Input? Complex array formula andrei Excel 9 02-03-2012 03:40 AM
How to capture start and ending Ref. Nos. in an array KIM SOLIS Excel 5 09-07-2011 07:43 AM
Look up an array based on user input johnsmb Excel 2 01-07-2011 01:12 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:20 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft