Login|Contact Us
Question and Answer

Programming

Ask a Programming Question, Get an Answer ASAP!

  • Ask A Question
  • Browse Answers
  • Meet The Experts
  • How JustAnswer Works

I want to use arrays in my program. Heres my declaration:

 
jatechexpert's Avatar
  • Answered by:jatechexpert
  • Computer Software Engineer
  • Positive Feedback: 96.8 %
  • Accepted Answers: 1280
Verified Expert
in Programming

Recent Feedback

Positive
Great Help! Will use again!
Positive
Type your review here...
Positive
great job
Positive
Awesome, thank you! I really appreciate your quick response and the solution.
Positive
Work was excellent and will recommend to everyone who needs programming help.
Positive
nice job
Positive
Great! Thank you!
Positive
Fast response and quality work
Positive
very helpful and did exactly what was asked for
Positive
Thanks

Customer Question

I want to use arrays in my program. Here's my declaration:

Dim zSiteName() As String

There are several arrays right, now. Right after I start I find out how many rows I will need. How do I change the array size to that variable value to take the memory drain off the system? and where do I do it? Do I do a ReDim on the Array in the program. There is no values to save at this point?

 

Optional Information:
Language (or Software): Excel
Browser (if necessary): IE

Submitted: 363 days and 20 hours ago.
Category: Programming
Value: $45
Status: CLOSED

Accepted Answer

Picture
Expert:  jatechexpert replied 363 days and 19 hours ago.

Hello and welcome to JustAnswer. I look forward to assisting you today with your question and providing the best answer possible.

hi

thanks for using justAnswer.com

you can resize the array using ReDim

Dim zSiteName() As String =New String(10)
ReDim zSiteName(2)

change the array size from 10 to 2

but using ReDim , data in the previous array will lost . For avoiding this, use Preserve with ReDim


Remember, if for any reason you are unsatisfied with my answer, we can continue the conversation until you’re satisfied and Accept my answer. I can address follow up questions at no extra charge and I’m always here to help. Thank you for using JustAnswer!

Expert TypeComputer Software Engineer
Category: Programming
Pos. Feedback: 96.8 %
Accepts: 1280
Answered: 5/9/2012

Experience: Master of Computer Application plus 5+ year experience in Software development

Ask this Expert a Question >
Customer replied 363 days and 18 hours ago.

I'm running my program loading my array and displaying it afterward using this message box command:

 

MsgBox ("Row= " & i & zSiteName(i) & " " & zAddress(i) & " " & zRoute(i) & " " zDriver(i) & Chr(10) & Chr(13) _
& " " & CB(i) _
& " " & HB(i) _
& " " & RL(i) _
& " " & AL(i) _
& " " & DS(i) _
& " " & SN(i) _
& " " & FV(i) _
& " " & PS(i))

It says its's a syntax error.

It was working until I added a couple in the middle. Is there a length problem? Or something else.

Customer replied 363 days and 18 hours ago.

Never mind that last question. I solved it myself. Thanks.

Picture
Expert:  jatechexpert replied 363 days and 18 hours ago.

hi
ok

Customer replied 363 days and 18 hours ago.

Sub RetrieveSite_Click()
zDate = InputBox("Please, enter a date")
u = Range("A" & Rows.Count).End(xlUp).Row "u = 25"
u = u - 1 "u = 24"
MsgBox ("Date & Range " & zDate & " " & u) "Works fine"

ReDim zSiteName(u)
ReDim zAddress(u)
ReDim zRoute(u)
ReDim zDriver(u)
ReDim CB(u)
ReDim HB(u)
ReDim RL(u)
ReDim AL(u)
ReDim DS(u)
ReDim SN(u)
ReDim FV(u)
ReDim SP(u)
ReDim PS(u)
ReDim BL(u)

For i = 2 To u "2 to 24"
zSiteName(i) = Cells(i, 1)
zAddress(i) = Cells(i, 2)
zRoute(i) = Cells(i, 3)
zDriver(i) = Cells(i, 4)
CB(i) = Cells(i, 5)
HB(i) = Cells(i, 6)
RL(i) = Cells(i, 7)
AL(i) = Cells(i, 8)
DS(i) = Cells(i, 9)
SN(i) = Cells(i, 10)
FV(i) = Cells(i, 11)
SP(i) = Cells(i, 12)
PS(i) = Cells(i, 13)
BL(i) = Cells(i, 14)

MsgBox ("Row= " & i & zSiteName(i) & " " & zAddress(i) & " " & zRoute(i) & " " & zDriver(i) & Chr(10) & Chr(13) _
& " " & CB(i) _
& " " & HB(i) _
& " " & RL(i) _
& " " & AL(i) _
& " " & DS(i) _
& " " & SN(i) _
& " " & FV(i) _
& " " & SP(i) _
& " " & PS(i) _
& " " & BL(i))

Next i " Goes to 24 showing correct values, then a box appears stating that subscript is out of range, instead of stopping"

Picture
Expert:  jatechexpert replied 363 days and 17 hours ago.

hi

sorry

i am not too much experienced in VBA

you put a new question for this

 
Tweet

4 Programmers are Online Right Now

Ask Your Question Now
Programming Questions Date Submitted
I need to make a inventory program for CS 115. I've had a very 5/2/2013
I want to get into programming but have no prior experience. 5/2/2013
Street Light Verilog Code 5/1/2013
Based on your new found knowledge and experience in problem 4/30/2013
this is a GUI done in C# Create an application in which a 4/29/2013
I am trying to use vba to click a button on a webpage but can't 4/29/2013
For LogicPro only:Help with Java Programming project. 4/29/2013
Drink Machine SimulatorWrite a program that simulates a 4/28/2013
Implement a class Car with the following properties. A car 4/27/2013
***The Doctor***I purchased a web template and I am currently 4/27/2013
RSS
Next 10 >
Ask A Programmer
Type Your Programming Question Here...
characters left:

Top Programming Experts

See More Programmers

In The News

Nbc
Washington Post
New York Times
Cnn
Learn More

How It Works

  • Ask an Expert
  • Get a Professional Answer
  • Ask Followup Questions
  • 100% Satisfaction Guarantee
Learn More
close
Find Expert answers related to your question.
Sign up using email
We will never post anything without your permission.
Already have an account? Sign in

Ask a Programmer

Get a Professional Answer. 100% Satisfaction Guaranteed.
150 Programmers are Online Now
Type Your Programming Question Here...
characters left:
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.
Truste
Contact Us | Terms of Service | Privacy & Security | About Us | Our Network
© 2003-2013 JustAnswer LLC
  • Pearl.com
  • JustAnswer UK
  • JustAnswer Germany
  • JustAnswer Spanish
  • JustAnswer Japan