Removing Elements
How do you remove an element from an array.
ex. dim array(1 to 6)
array(1)=6832 array(2)=1238 array(3)=7842 array(4)=8831 array(5)=2294 array(6)=1985
'the numbers don't mean anything ' How do I remove say the 3rd part (7842) of the array? is there a 'function for that or do I need to make one? "And the day shall come when the Viper will take his throne"
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Removing Elements From A Array
Removing elements from a array as I scroll through a listing of files in a text list. As I find the file I wish to remove it from my array. Example 1.txt after finding the file I wish to remove it from my list. When I try Redim Preserve I get a “array is fixed or temp. locked”
How do I unlock to edit array or is there a better way to remove an element from my array ?
Removing All Elements From An Array
hi there ...
Is there something special I need to do inorder to get this to work for me...
im running windows 2000 server ... and the array I'm attempting to verify that is empty or not is returned from the "Filter" method..
checkIfEmpty = Filter(stringArray, "somestring", True, vbTextCompare )
If (Not checkIfEmpty) = -1 Then
' this is not getting executed..
End If
Note : Filter apparently returns an empty array when "somestring" is not
found in 'stringArray'
thanks ..
deez
Removing Attributes On XML Elements
Anyone know a quick way to remove all attributes of an element using the DOM without traversing through each attribute? Any suggestions appreciated...
Removing Elements From Arrays
Can anyone tell me how to remove elements from an array at any position I choose. At the moment I read a text file into the array. Now I want to search that array for a particular file in the array and delete it. I can find the file but do not know how to remove it from the array.
Dim temp_array(1000) As String
For i = 0 To total_size - 1
position = InStr(1, temp_array(i), SearchString, 1)
'Found file
If position > 0 Then
temp_array(i) = "" <- I know the code goes here, but this only blanks it and not remove.
End If
Next i
Can someone please help this frustrated vb beginner?
Removing All Elements From An Array
I declared an array like:
Dim MyArray() as Integer
In a procedure I have:
Redim MyArray(1 to 5)
How do I remove the 5 elements in this array?
I tried:
Redim MyArray()
But that doesn't work. Is it possible?
Wilbert
Removing Array Elements
Hi
I have an array as follows:
ArrName(0)="Carl"
ArrName(1)="Sarah"
ArrName(2)="Fiona"
ArrName(3)="Paul"
Can you please let me know how I can remove ArrName(2) and decrease the arrName length by 1, for example. Would I have to do the following:
ArrName(2)=ArrName(3)
Remove ArrName(3)
Or is there an easier way
Removing Elements Of An Array
ok.. i got this array that will be dimmed without bounds (dynamic) and i will allow a total of 5 elements in the array.. the reason i am not going to just dim it Dim MyArray(4) is because it is a HUGE UDT and I don't want to use up memory until I need to for it.. because the user might not open up 5 forms to need the 5 UDTs...
anyways... Lets say they do open 5 forms and I add a new element to the array and redim it..and then the close one of the forms.. i would want to remove that element from the array.. and move all remaining elements to the beginning..
so if they close the second form.. i would want to remove element 1 from the array (its 0 based) and move elemnts 2-4 up so that it would be a 4 element array...
how would i go about doing this??? did that make any sense?
Removing Array Elements
I am writing a computer version of a board game. I have an array of the game cards that should pop up when the user lands on the correct space. I want to be able to select any one of these cards at random but never twice in one game. What would be a good way to go about this (remembering that a game may last several weeks, so it needs to be retained on disk what cards have been picked).
I have designed graphically the card and now I just want the correct message to pop up within the graphical representation as well as a couple parameters to define how much money is taken from or added to the players bank account.
Any ideas? I have considerd an array of pointers that a random number is used to select from the array a single element but then after it has been used removing the element from the array and reitinizing and all that is a pain. Thanks for your help.
------------------
SCUZ
Removing Array Elements
I am writing a computer version of a board game. I have an array of the game cards that should pop up when the user lands on the correct space. I want to be able to select any one of these cards at random but never twice in one game. What would be a good way to go about this (remembering that a game may last several weeks, so it needs to be retained on disk what cards have been picked).
I have designed graphically the card and now I just want the correct message to pop up within the graphical representation as well as a couple parameters to define how much money is taken from or added to the players bank account.
Any ideas? I have considerd an array of pointers that a random number is used to select from the array a single element but then after it has been used removing the element from the array and reitinizing and all that is a pain. Thanks for your help.
------------------
SCUZ
Removing XML Child Elements
Hi: I understand how to append a new child element onto an XML document, but am having trouble removing/deleting elements. Anybody have an example? Any examples or tips would be mucho appreciated. Thanks.
D. Sterling
Emperor of Clipperdom
Removing Elements From Dynamic Arrays
Hello, I'm making a simple VB program that tests the definitions of Vocabulary. I know how you can add elements to an array, but how do you remove elements from an array, and still preserve all the information in the array? Thanks in advance.
Removing Commas From Array Elements
Hi,
Does anyone know how to find and replace a comma with a space within an array of strings?
Basically, what I have is an array of strings such as :
x(0)=0156,
x(1)=0050,
x(2)=0045,
x(3)=0052
How do I remove the commas from these elements so that my elements end up like:
x(0)=0156
x(1)=0050
x(2)=0045
x(3)=0052
I was going to using a subprocedure for this. but I'm open to other ideas and suggestion.
Cheers.
WW
Containing Elements
Hi there, and thanks for reading.
I have a web page with several pairs of controls. They are, in fact, text fields and buttons, the idea being that the button click opens a modal dialog, whose return value is dropped into the text field.
Because I add more and more of these pairs at runtime through client side script, each have button has the same object name and ID, as do the text fields. I scripted the dialog in a test page like this:
window.event.srcElement.form.txt.value = window.showmodaldialog(blah blah)
I.e., the srcElement is the button and I use the form to identify in which object with ID="txt" to place the result. Works fine.
However, now I come to the real page, I have the whole situation already within the main form, and so I cannot use a nested form to effectively group the buttons to their relevant text fields.
I have tried using DIV and Spans, but of course they don't work, so what 'containing' object can I use within a form that will permit the syntax window.event.srcELement.[whatever].txt.value = ResultofmodalDialog?
thank again people....
surrendermonkey
Colon-Hyphen-Close-Bracket
Tell How Many Elements Are In An Array
How do i tell how many elements are in an array? The array is created by another function, so i dont know how many there are by defining them in the varible like you normally would. Thanks.
Problem With Elements
I reached maximum for the number of control elements allowed on one form ... Can you help me plz ... I need 10 - 30 more control elements and dont even know how to get them in ...
plz help me im a n00b
No. Of Elements In Array
Hi, i was just wondering if there is a easy way to find out the number of elements in an array.
# Of Elements In Array
I have an array that was created using the 'Filter' function from another array. I need to know how many elements were returned in this new array, and really don't know how to go about that...
Efficiency is an issue as the original array had thousands of elements, and there may be hundreds or even thousands in the new one as well.
Help!
Add Elements To Array
Im stuck
I can split a text file to an array ok but I would like to add 10 empty lines or elements at the end of the array.
How do I do this?
Would I use vbcrlf or would I loop through the array and add the elements.
Open Cdlg.FileName For Binary As #intFileHandle 'Open the text file
text = Space(LOF(1))
Get #1, , text
array = Split(text, vbCrLf)
thx for any help
Deleting Elements
hi all, i am creating an alternative voting system, which is where voters order their preferences eg.1st choice,2ndchoice etc. the votes will be stored in a 2-dimensional array. what i would like to know how to do, is that each voters 1st choices are added up and the candidate with the least votes is eliminated (basically removing the persons vote from the array)
anyhelp is much appreciated
How To Map Elements According To Line No's
Hi, iam struck at 1 point.please help me sothat i can complete my projectwrok...
The problem is..........
Suppose we had a flatfile
1 1 2 3 4
31 4 2 3 1
21 3 2 1 4
14 2 3 4 1
and i sorted index,and i got the below
1 1 2 3 4 -- > line 1
14 2 3 4 1--->line 2
21 3 2 1 4---->line 3
31 4 2 3 1--->line 4
and,now what i requires is accoding to the line numbers 1 is not sorted .So now we have to make a mapping like
line 2 --> 14
3 ---> 21
4---> 31
Finally then we have to replace the line numbers to the sorted elements like
1 1 2 3 4
2 2 3 4 1
3 3 2 1 4
4 4 2 3 1
This is what i need please help me........
What i did is sorting part,the code is like ......
VB Code:
Dim data As StringDim Index As LongDim IndexLength As LongDim Elements() As StringDim filename As String filename = "d:cafewok1sam1.txt" Open filename For Input As #1 'move to the start of nodes coordinates Do While Not EOF(1) Line Input #1, data data = UCase$(Trim$(data)) If InStr(data, "*ELEMENT") > 0 Then Exit Do Loop ReDim Elements(100)Do While Not EOF(1) Line Input #1, data data = UCase$(Trim$(data)) ' This isn't necessary If Left$(data, 1) = "*" Then Exit Do IndexLength = InStr(data, ",") - 1 If IndexLength > 0 Then Index = CLng(Left$(data, IndexLength)) If Index > UBound(Elements) Then ReDim Preserve Elements(Index) Elements(Index) = data End IfLoop'Close #1 For Index = 1 To UBound(Elements) If Elements(Index) <> "" Then MsgBox "The Elements are " & Elements(Index) ' MsgBox " The Sorted Elements " & Elements(Index) ' Close #1 'Close file. 'End If 'Next Index 'Loop End If Next Index
so now i need is how to map the sorted elements according to line numbers....please help me iam at the end of my project..
How To Map Elements According To Line No's
Hi,Please help me i am struck at one pont...
Suppose we had
1 1 2 3 4
31 4 2 3 1
21 3 2 1 4
14 2 3 4 1
and i sorted index,and i got the below
1 1 2 3 4 -- > line 1
14 2 3 4 1--->line 2
21 3 2 1 4---->line 3
31 4 2 3 1--->line 4
and,now what i requires is accoding to the line numbers 1 is not
sorted .So now we have to make a mapping like
line 2 --> 14
3 ---> 21
4---> 31
Finally then we have to replace the line numbers to the sorted
elements like
1 1 2 3 4
2 2 3 4 1
3 3 2 1 4
4 4 2 3 1
[highlight=VB]
Dim data As String
Dim Index As Long
Dim IndexLength As Long
Dim Elements() As String
Dim filename As String
filename = "d:cafewok1sam1.txt"
Open filename For Input As #1
'move to the start of nodes coordinates
Do While Not EOF(1)
Line Input #1, data
data = UCase$(Trim$(data))
If InStr(data, "*ELEMENT") > 0 Then Exit Do
Loop
ReDim Elements(100)
Do While Not EOF(1)
Line Input #1, data
data = UCase$(Trim$(data)) ' This isn't necessary
If Left$(data, 1) = "*" Then Exit Do
IndexLength = InStr(data, ",") - 1
If IndexLength > 0 Then
Index = CLng(Left$(data, IndexLength))
If Index > UBound(Elements) Then ReDim Preserve Elements(Index)
Elements(Index) = data
End If
Loop
For Index = 1 To UBound(Elements)
If Elements(Index) <> "" Then
MsgBox " The Sorted Elements " & Elements(Index)
' filename = "d:cafewok1sort.txt"
' Open filename For Input As #Elements(Index)
' Do While Not EOF(1)
' Line Input #1, Elements(Index) then exit do
End If
Next Index
So i am getting the sorted elements but now how to map the elements according to cout...
This is what i need please help me........
How Do You Know How Many Elements An Array Has...?
I know this is probably a really noob question... but how...?
I thought that I remember myself being able to use array.UBound() or something like that, but it doesn't work anymore.. or maybe I just remember wrong... So how do you determine the length on an array?
Recordset Elements
When I say "SELECT * FROM tablename ", then create a recordset based on this query, how can I know how many elements are in the recordset? I.E., how many fields are in the table? Please NOTE: I'm not interested in how many records are returned. I need to know how many elements there are in my recordset (Ex: Rs(0) through Rs(?) )
Max Number Of Elements
Is there a way to determine the total number of elements in an array?
Like if I did this:
Code:
Dim stuff As Variant
stuff = Split(Text1.Text,",")
that turns stuff into an array. Is there a way to return how many elements are in that array??
Types And Their Elements
Hail,
Let's say you have:
Public Type Test
Test1 as string
Test2 as string
Test3 as string
End Type
Is there a way to loop through the elements? For example, let's say I would want to assign three values (1, 2 and 3) to each of those, is there a way to loop them instead of doing
Dim TestType as Test
TestType.Test1 = 1
TestType.Test2 = 2
TestType.Test3 = 3
Could I do something like
For X =1 to 3
TestType.? = X
next
Retrieving XML Elements
Hi All,
I need some help with an XML project, I am trying to only return a certain number of attributes from an element and then assign these to variables WITHOUT having to loop through every attribute in the element.
As an example, what I need is:
-- Example XML File --
<ROWDATA>
<ROW ATTRIBUTE1="AAA" ATTRIBUTE2="BBB" ATTRIBUTE3="CCC" ATTRIBUTE4="DDD"/>
<ROW ATTRIBUTE1="111" ATTRIBUTE2="222" ATTRIBUTE3="333" ATTRIBUTE4="444"/>
</ROWDATA>
-- End XML File --
I need to create a selectNodes query that will ONLY RETURN attribute1 and attribute4, is this possible?
This is a Visual Basic 6 project.
Thanks,
Lanky
Anchors Elements
I have hAnchor As HTMLAnchorElement that points to <a><img></a> on a document.
I want to access the <img> element inside it.
I try many ways but I can't set it to the way I want.
Set hImg = hAnchor.getElementsbyTagName("img")
don't work type mismatch
HELP ME.?
How Many Elements In An Array
Hi!
I have a function that takes an array of integers as argument. This is a dynamic array so I don´t know how may elements in this array.
How do I find that out?
Thanks in advance
Jen
Adding Elements
I have a web page which is nicely generated through a database query. Basically it's a form that can be changed on any occasion. These forms have text boxes which need to be added up for a total box at the bottom of the page. There are two issues. First i would like to be able to add those elements on the client side (since i'm not actually storing the added total). Secondly the text boxes are named differently to relate to a key in the database for later updating and inserting. I need to be able to auto generate Javascript on the server side to add all the elements on a 'onchange' event. Below is an example of what i mean.
function TOTAL_onchange() {
var temp = 0.00;
temp = Number(document.thisForm.TOTAL.value) +
Number(document.thisForm.TOTAL.value);
document.thisForm.TOTAL.value = temp;
}
the TOTAL variable will be replaced and repeated according to how many elements exist on the page. If you need any clarifiaction please let me know.
Thanks
VBA, Access, And Accessing Elements...
hi, I am writing a database using ms access and have a bunch of data on a form with a button I defiend. now, when you click the button, I want to check the value of a text box that is on the form (txtid). however, every tiem I try to check use or display the value I get "you can not access a property of method for a control unless the control has the focus." how do I get around this? its weird... I can change its visiblility, but can't modify the data?!? what am I doing wrong?
Code:
MsgBox (Me![txtID].Text)
if you can help me out... it woudl be greatly appreciated... thanks!
Delete All Elements Array
Hallo,
there is any way to delete all the elements of an array.
I have a global array:
Global lRow(excelLineNumber) As String
I try with:
reDim lRow(0)
reDim lRow
But it doesn't function.
Thanks.
Adelio
Detecting Whether An Array Has Elements
I have an array, that I have dimensioned with zero elements:
Dim Cat()
I need to know if the user has loaded data into the array (causing it to be redimensioned to some, UNKNOWN size) before I call certain subroutines. I've tried:
If Cat()....
If Cat() = NULL....
If Ubound(Cat()) = 0....
They don't work. I get errors due to the subscript being out of range if the array isn't dimensioned to some size. In this case, so far, I simply position a detection statement at the start of the routine "If Ubound(Cat()) > 0", and if an error is generated because of the subscript problem, I determine that there must not be any elements in the array, and just exit either with or without an error message, depending on whether the user may be loading a form (which is where I check in one instance) in which some other function not requiring the array may be the desired goal. I then leave array related errors associated with functions called from the form to specific functions that MUST use the array.
Is there a better way to do this? There MAY be some element of a gamble in my use of the error generated by the "If Ubound(Cat()) > 0" statement for an array with no elements that I am simply missing, even if it is the only statement associated with the error message. It also makes it hard to use a "catch-all" error message for an entire routine, where I am entering a form and may want to enable access to some buttons that don't need the array information.
Thanks.
Check If Array Has 0 Elements
So I declare an array with an undefined amount of elements, such as "Dim Array() As Integer" with the intention of resizing it later. Is there a function I can use that will check to see if the array is still empty? Calling Ubound on it gives a Subscript Out Of Range error.
How To Compare Elements Of An Array
Hello!
Have a look at this
Dim Temp(1 to 5) as byte
Temp(1) = 1
Temp(2) = 2
Temp(3) = 2
Temp(4) = 3
Temp(5) = 4
As you can see, 2 of elemets above have same value.
I want to know how to detect if 2 elements have same value, and add them. In this case, the sum is 4.
Also, how to detect if there are 2 pairs, e.g:
Temp(1) = 1
Temp(2) = 1
Temp(3) = 2
Temp(4) = 2
Temp(5) = 5
Two pairs here is: Temp(1) = Temp(1) | Temp(3) = Temp(4)
The sum of both pairs = 2 + 4 = 6
Selected Elements At The Top Of A Listbox?
Hello, I want to do multiselection on a list box with many items. My pourpose is to see at the top of the list box the selected elements when finish the selection. I'm using a curious custom listbox that automaticaly expands at get focus.
Can you help me please?
Thank you very much
here's the code I use
(put a listbox and a timer "tmrWait")
------------------------------------------
Option Explicit
Private Sub Form_Load()
tmrWait.Interval = 50
tmrWait.Enabled = False
List1.AddItem "cat"
List1.AddItem "dog"
List1.AddItem "horse"
List1.AddItem "elephant"
List1.AddItem "lion"
List1.AddItem "panda"
List1.Height = 120
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With List1
If X < .Left Or X > .Left + .Width Or Y < .Top Or Y > .Top + .Height Then
.Height = 120
tmrWait.Enabled = False
End If
End With
End Sub
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
tmrWait.Enabled = True
End Sub
Private Sub tmrWait_Timer()
List1.Height = 2000
End Sub
------------------------------------------------
Checking If Array Has Elements
I have an array declared like this...
Dim a() as integer
It may or may not have been ReDim'ed to include elements. How can I check if it has elements or not? (Checking it with LBound throws an error.) I suppose I could just make a function to check it with LBound, and if it throws an error then return false, but I wondered if there's a better, more elegant way.
Counting Array Elements
is there an easy way to count the number of the element in an array? Im creating a flat array with the Split function and I want to know how substrings were entered into the array.
How Do You Refer To Menu Elements
I am trying to enable a preview menu
option only if certain conditions are met.
In the menu Editor its name is mnuPreview. But If I use mnuPreview.Enabled = True I have a runtime error. What is the mistake?
|