Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




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....surrendermonkeyColon-Hyphen-Close-Bracket




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How Many Elements Does Arr(50) Contain?
If I Dim arr(50) as integer, do I get 0 - 49 or 0 - 50?

If it is 0 - 50, why? Most languages do 0-49, is there any reason VB is different?

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.

Max Elements In Array?
both my text books don't provide an answer. ty for ur help.

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

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"

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

Removing Elements
what is a collection please?

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??

How To Know Whether Array Is Having Any Elements Or Not?
Hi all

can any one tell "How to know whether array is having any elements or
not?"

thanks & regards,
Sridhar CS

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.?

Elements Of A String
How can I get the 3rd or 4th Element of a String

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.

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 ?

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
------------------------------------------------

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

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.

Index Of Elements In A DBCombo
How can I know the index of a selected item in a DBCombo?

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.

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...

On The Fly Creation Of Form Elements
Simple enough - what's the routine for creating - say - a picturebox at runtime?

Thx.
Mith

On-the-fly Creation Of Form Elements.
Is it possible to, say, create a button or image or listbox on the fly?

How would one go about doing this? 0.0*

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 &gt; 0 Then
temp_array(i) = "" &lt;- 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?

Number Of Elements In Array?
Is there a way in vb6 to find the number of array elements?

Anything similar to sizeof i can use?

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?

Can I Randomize Array Elements?
If I have this:


Code:
Dim myarray(0 to 4, 0 to 3)]

For x = 0 to Ubound(myarray)

'get array info
'pass array info to a sub

Next x

This array has 4 elements that I pass to a sub that changes parameters of a calculation. It passes 5 diff sets of data [myarray(0 to 4, 0 to 3)]. There are times when I want to pass myarray(2,0) before I pass myarray(0,0). Is there any way to randomize with array elements get passed?

How To Reference UserControl Elements From A Frm Or Bas
I am faced with the task of converting an existing ActiveX DLL to an ActiveX OCX. The control has a main form, so basically what I need to do is change it so that instead of being instantiated in code, it can be dropped onto a container form at design time. So I started a brand new OCX project with a UserControl.

The problem I am having is that I do not seem to be able to access form elements of the UserControl from the other cls and bas files that are in the project. I used to have a line like:

Code:
Form1.txtBox.Text = "yadda yadda"
but now it doesn't recognize

Code:
UserControl1.txtBox.Text = "yadda yadda"
Are those things restricted now?

Array Elements Combinatorics
Lets say we have an array with N elements. How we can have all the possible combinations between those elements?

Is it possible to store those combinations to a database?

e.g.

{1,2,5,6,9}

(1,2) (1,5) (1,6) (1,9) (2,5) (2,6) (2,9) (5,6) (5,9) (6,9)
(1,2,5) (1,2,6) (1,2,9) (1,5,6) (1,5,9) (1,6,9) (2,5,6) (2,5,9) (5,6,9)
(1,2,5,6) (1,2,5,9) (1,2,6,9) (1,5,6,9) (2,5,6,9)

Combinatorics - How To Combine Elements
Lets say we have N set of M elements (not every set hgas the same number of elements). How can we program to have all possible combinations between the elements, if we choose only one element from each set.

e.g.

{1,2}, {1,3,4}, {5,6}

1-1-5
1-1-6
1-3-5
1-3-6
1-4-5
1-4-6
2-1-5
2-1-6
2-3-5
2-3-6
2-4-5
2-4-6

How To Convert Elements Of An Array
hi.

I was just wondering if anyone can tell me how I would be able to convert string elements of an array into integer values. For example, I have an array that encompasses a range of numbers; however, these numbers are recognized as strings, so when i sort let say- 1,2,5,3,12 ... i get 1,12,3,5-

if anyone can help... that'd be great. Thanks

Creating Dynamic Elements
Hi all,

First time posting here, go easy on me. This is what I want to do in VB.

I'm writing a program that cubes packages. I can write it so I can cube out 1 package (Easy formula, LxWXH1542 *15) and display it but I want to take it a step further and do the following.

- A prompt asks the user how many packages they want to cube
- User enters #
- That # displays 4 different boxes, 1 for the real weight, and the other 3 are for the Length, Width and Height of the actual package
- then after you add up all the weights and cube and compare them, the final cubed weight is displayed.

I have no idea where to start on this. I figure the message box is the most obvious but I don't know where to go from there, an array?

Thoughts?

Easy Way To Add All The Elements Of An Array?
Right now I'm writing out each array address and adding them together as follows:

MyArray(0,0) + MyArray(1,0) + MyArray(2,0) + MyArray(3,0)...

I'm doing this for 59 elements, then dividing this value by 60 for an average.

I'm just wondering if there is some other code that you can direct the addition of all the elements of the array more easily?

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

Number Of Elements In Array
Hello, I need to know how to get the number of elements in an array.
Like Len(), but not with a string but with an array.
Anyone who could help me out?

Combinatorics - Elements In A Record
Lets say we have N sets of M elements.
Not every set has the same number of elements!!

How can we put every set as one record which contains these elements?

How can we program to have all possible combinations between the elements, if we choose only one element from each set (record).

e.g.

{1,2}, {1,3,4}, {5,6}

1-1-5
1-1-6
1-3-5
1-3-6
1-4-5
1-4-6
2-1-5
2-1-6
2-3-5
2-3-6
2-4-5
2-4-6

Copyright © 2005-08 www.BigResource.com, All rights reserved