Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

remove empty elements in array

Posted on 2010-11-09
1
Medium Priority
?
282 Views
Last Modified: 2012-06-27
how do i remove unwanted empty strings from an array?

ex
processarray(0)=""
processarray(1)="280"
processarray(2)=""
processarray(3)="100"

would like the array now to be:
processarray(0)="280"
processarray(1)="100"

in access 2010 vba
0
Comment
Question by:PeterBaileyUk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 42

Accepted Solution

by:
Meir Rivkin earned 2000 total points
ID: 34092056
from http://www.tek-tips.com/viewthread.cfm?qid=1470647&page=9
Public Function cleanArray(varArray() As Variant) As Variant()
  Dim tempArray() As Variant
  Dim oldIndex As Integer
  Dim newIndex As Integer
  ReDim tempArray(LBound(varArray) To UBound(varArray))
  For oldIndex = LBound(varArray) To UBound(varArray)
   If Not Trim(varArray(oldIndex) & " ") = "" Then
     tempArray(newIndex) = varArray(oldIndex)
     newIndex = newIndex + 1
   End If
 Next oldIndex
 ReDim Preserve tempArray(LBound(varArray) To newIndex - 1)
 cleanArray = tempArray
End Function

Open in new window

0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question