473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Subscript out of range error

48
I am using a function to delete the "@" from address field. this function is also supposed to remove the unnecessary "0" from the beginning of a street address. i am this function in a simple query but this error "Subscript out of range"
Expand|Select|Wrap|Line Numbers
  1.  
  2. 1.Public Function StripDup(ByVal varWith As Variant) As String
  3. 2.      Dim intX As Integer, intY, intZ As Integer
  4. 3.      Dim strWith As String
  5.  
  6. 4.     If IsNull(varWith) Then
  7. 5.         StripDup = ""
  8. 6.       Exit Function
  9. 7.     End If
  10.  
  11. 8.     StripDup = Trim(varWith)
  12. 9.     varWith = Split(StripDup, " ")
  13. 10.     For intX = 0 To UBound(varWith) Step 1
  14. 11.        If Left(varWith(intX), 1) = "@" Then
  15. 12.            varWith(intX) = LTrim(varWith(intX))
  16. 13.        End If
  17. 14.     Next intX
  18.  
  19. 15.    For intY = 0 To Len(varWith(0)) Step 1
  20. 16.        If Left(varWith(0), 1) <> "0" Then Exit For 17.Else varWith(0) = LTrim(varWith(0))
  21. 18.    Next intY
  22. 19.    StripDup = ""
  23. 19.    For intZ = 0 To UBound(varWith)
  24. 20.    StripDup = StripDup & " " & varWith(intZ)
  25. 21.    Next intZ
  26. 22.    StripDup = LTrim(StripDup)
  27.  
  28. 23. End Function
  29.  
Attached Files
File Type: zip Data1.zip (373.7 KB, 67 views)
Dec 6 '11 #1
5 1745
Rabbit
12,516 Expert Mod 8TB
What line is it erroring out on? I see multiple places where it can go out of range.
Dec 7 '11 #2
almaroc
48
I've fixed the out of range error how i am not getting the result that all i am getting is the value in table. my goal is to remove the @ from the address and also delete the zeros "0" from the beginning of the address.
Dec 7 '11 #3
Rabbit
12,516 Expert Mod 8TB
That's a different question. Please post how you solved the out of range error and then create a new thread for your new question.
Dec 7 '11 #4
almaroc
48
I have the wrong variable in line 20. I just replaced IntxX with Intz
Dec 7 '11 #5
almaroc
48
i have posted the question under How to delete unwanted characters from an address field.
Dec 7 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Lukelrc | last post by:
Hi, I have some VBscript that lists the files in a folder. What i want to do is populate an array with the file names and then use that array to populate a list box. I have got as far as...
2
by: jv | last post by:
I have a form that is used every day to create quotes. However, every 2 weeks or so a user would randomly get an error 9 - subscript out range message. I'm not using any array in this form. Does...
2
by: kscdavefl | last post by:
When I run the following code: private void applicationPermissionGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (e.Item.ItemType ==...
8
by: VB Programmer | last post by:
I'm acutally using VB6, not VB.NET, but I couldn't find the newsgroup for version 6.... I need help for something that should be simple. I keep getting a "subscript out of range" error and...
2
by: Henry J. | last post by:
Has anybody run into this index out range exception when opening and then closing a collectionEditor from within a PropertyGrid? I use PropertyGrid to edit configurations in my application. One...
4
by: Sheldon | last post by:
Hi, I have a written a script that will check to see if the divisor is zero before executing but python will not allow this: if statistic_array > 0.0: statistic_array =...
0
by: dalaeth | last post by:
I have searched Google high and low and haven't found anything that works. Here's my problem, hopefully someone will be able to help! I'm using 1.1 Framework, and ODP.NET 9.5.0.7 on a Windows...
6
by: bloukopkoggelmander | last post by:
Hi all. I use Access 2007. I have linked tables set up to a AS400 server. When I try to split the database, I get the following error : Subscript out of range. I have no idea what this mean. I...
1
by: fperri | last post by:
I have converted a database I finished into an MDE. I'm supposed to be delivering it today. I get a subscript out of range error when the user tries to print a report from the print preview window....
1
banning
by: banning | last post by:
Im a PHP developer and I officially HATE ASP why does my code give me this error? ERROR: "Microsoft VBScript runtime error '800a0009' Subscript out of range ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.