This may be a very simple question but I'm very noobish with VBscript and I've spent 2 sleepless days trying to figure out this simple simple problem...yes i'm hopeless with programming but really need your help on this guys..please !
Problem = I have an excel file with one column of numbers as shown below :-
I want to put all those numbers into a 1-dimensional string array. I don't need to include the row and column names, as long as the number in each row refers to index 0, index 1, index 2 and so forth of the string array.
So the string array should be like this :-
strArray(0) = 500 strArray(1) = 501 . . .
strArray(8) = 100
------------------------------
This is what I've done so far to extract from the excel file. But just dunno how to put the info into a string array.
Any ideas please ????
I'd really appreciate the help. Thanks !
< Message edited by dante22879 -- 5/17/2006 1:33:15 PM >
Try this, the Join command will combine all elements of an array into a single string
For Each objNicConfig in colNicConfig intIPSecReturn = objNicConfig.EnableIPSec(Join(arrExcelValues) arrPermittedUDPPorts, arrPermittedIPProtocols) Next
if you look at Microsoft's own sample code, you'll see that they use something like
arrPermittedTCPPorts = Array("80", "443")
to initialize this variable. Can you test your code with arrPermittedTCPPorts initialized exactly as this?
Looking at your "read from Excel" code, I can think of only one possible problem: If the values are numbers, your array wouldn't look like Array("80", "443") but Array(80, 443). This could cause problems. To test that, just replace
Here's the code I've modified again but still wont' work......
Please someone help me...i'm almost at my wit's end. :-(
I have 16,000 over ports to add in manually for the tcp/ip filtering process on 20 over servers....so you can imagine how important it is for me to get a script working....
Forgive me if I'm way off base. But couldn't this be made simpler by saving the Excel file as a CSV first (you would need to remove all information besides the list of ports starting at A1)? Then read the entire file into an array and then use it to make the string needed? You may want to make a separate csv for each protocol type or limit the reading of the array based on row number
I'd stick to the Excel way, but if you want to work with the .csv the fastest way is to remove the last vbCrLf manually in the file, read and split the list into myArray myArray = Split(strText,vbcrlf) and use myArray like this: intIPSecReturn = objNicConfig.EnableIPSec( myArray, arrPermittedUDPPorts, arrPermittedIPProtocols) Don't convert it into a string again.
I've managed to crack it......Nothing special as most ppl perform port filtering at the firewall side....but oh well, at least I've learnt something from you all ! Once again, thanks a lot !
Here's the code if anyone needs it (using .csv file to generate range of port numbers) :-