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




Set Arrays Equal


I would like to transfer the data from one array into another, both of the same size. I would like to do this without going through a loop and assigning the values one at a time. I am doing this so I can compare the arrays.

psuedocode:

do

newarray = somedata

does oldarray = newarray?

if not yes then
do action
endif

oldarray = newarray

loop

thx




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Equal Arrays
what is a good (and fast) way to check to see if two arrays contain the same data? Can this be done without a loop?

Can I Separate A Report's Data By Two Kind, Equal To And Not Equal To.
Hi,
Here I have a simple question . I have a report which will get data from two table.In the detail field. I want to separate it into two part of data. and this two part will separate by a line or any thing can identify it..
I try to do in Datapart by this way.
Two fiels I need for filter is SID and Unit.
A and B are table name.
Command 1:
Select A.Name ,B.* from A,b where A.SID =B.SID and B.SID=? and B.Unit=?
child Command :
select * from B where and B.SID like ? and B.Unit unlike ?
The command works but nothing come out at the details of report.(It has data in the recordset)
Does anybody have experience about. If I use crystal report to do it. Will it be easier.
If anybody can give me some idea, it will be very great!

millions of thanks!



wky086

Setting Control Arrays "Equal" To Each Other
Hi everyone. If I have a control array imgArr1() with 12 "parts" to it (elements from 0 to 11), is there a way I can make another array "equal" to it?

For example, I want a user defined control array imgArr2() (let's say it is introduced into the program at runtime with "Dim imgArr2()") to have the exact same elements as in imgArr1() [the same controls for each element with all of the same properties etc).

I have tried this but it doesn't work:

Code:
Dim imgArr2()
Dim i as integer

'imgArr1 already exists as an object before Runtime
For i = 0 to imgArr1.UBound
imgArr2(i) = imgArr1(i)
Next

Your help is greatly appreciated.

Edit:
Okay, I realize that there is probably an issue with what I am trying to do, considering the control array has no "space" on the form.
I think what I erally want is just to let a variable stand for a control array (and all of its elements).

Like, x = imgArr1().

When Double Are Equal But Evaluate To Not Equal???
Here is a question. Why does this print my debug message?

strBegBal = "-5697.27"
strMnthTrans = "-2534.13"
strEndBal = "-8231.40"


Code:
Dim dblBegBal As Double, strBegBal As String
Dim dblMnthTrans As Double, strMnthTrans As String
Dim dblEndBal As Double, strEndBal As String
strBegBal = Format(strBegBal , "##########0.00")
strMnthTrans = Format(strMnthTrans , "##########0.00")
strEndBal = Format(strEndBal , "##########0.00")
dblBegBal = CDbl(strBegBal)
dblMnthTrans = CDbl(strMnthTrans)
dblEndBal = CDbl(strEndBal)

If (dblBegBal + dblMnthTrans) <> dblEndBal Then
''there is an error
Debug.Print "ERROR"
End If


What am I doing wrong?


Thanks...

Dates Equal But Not Equal
I have this annoying problem and I am wondering if any of you have dealt with it before.

I have two variables that have the date stored in them. When I look at the text output of these two variable they are the same but if I do a comparison of these two variables VB says they are not the same.

In the Immediate Window I get the following:
Code:
? TempDate >= NextRunTime
False
? TempDate
11/2/2001 2:20:00 PM
? NextRunTime
11/2/2001 2:20:00 PM
? TempDate - NextRunTime
-2.18278728425503E-11
I am probably rounding off somewhere I shouldn't be. Has anyone seen this before and is there a work around?

Thanks

Complex Multi-dimensional Variant Arrays Holding Other Arrays (sub-arrays?)
Hi there folks, I have a rather complicated problem on my hands at the mo for which I can't find a solution alone!

I'm currently working on some software for my company to keep a weekly record of the following:

Various receipts (i.e. cash, cheque, card, other & additional information, each additionally entered by the user as a daily total)

Expenses for business stock, recorded per supplier on a purchase by purchase basis

Other various expenses, i.e. motor fuel, phone, light, heat etc. on a weekly basis.

The form to which the above relates to is attached and viewing it would help you understand what I mean.


***Please note, when viewing the form, the project within VB6 should have the component "Microsoft Tabbed Dialog Control" activated in order to view it properly!***


I have already thought of a way to use multi-dimensional variant arrays to store data week by week, which, although I have not yet written the code for, I imagine would be fairly easy to accomplish.

My problem is that I have just purchased one of Microsoft's books on Visual Basic, "Programming Visual Basic 6.0" written by Francesco Balena, which has given me a completely alternative approach on how to deal with the week by week data.

It must be mentioned that although my original method I presume will work fine, MOST of the data (i.e. text boxes if you view my form )for each week will be left blank which is a waste of time and will slow down my application down.

Francesco Balena mentions in his book that an array can also hold an additional array (see page 177, if you have the book, "Arrays of arrays") saving memory for the application.

My original method is to basically create a multi-dimensional array, collecting ALL data for each week, including those which are NIL. A ROUGH example is as follows:

arr(wkNo,DayNo,ReceiptType,)    'ReceiptType as integer
arr(wkNo,ExpenseType)    'ExpenseType as integer

As I mentioned, there will be a lot of memory wasted with this type of array as not every different type of expense will be encountered each week. (I.e. once the array has been created during run-time, there will be a fixed number of entries for each dimension)

Francesco's book mentions an array that can hold an additional array, a sub-array. Something that looks like arr(1)(2) for example.

Although I can roughly grasp the method in particular, I am trying to find out a way how I can create a "sub-array" to deal with the week by week expenses so that they can be stored as need be, but when there is no data to save, then no sub-array is created.

Sorry if the above sounds confusing, but I can't think of any better way to describe what's going on! Like I said, have a look at the attached form!

Complex Multi-dimensional Variant Arrays Holding Other Arrays (sub-arrays?)
Hi there folks, I have a rather complicated problem on my hands at the mo for which I can't find a solution alone!

I'm currently working on some software for my company to keep a weekly record of the following:

Various receipts (i.e. cash, cheque, card, other & additional information, each additionally entered by the user as a daily total)

Expenses for business stock, recorded per supplier on a purchase by purchase basis

Other various expenses, i.e. motor fuel, phone, light, heat etc. on a weekly basis.

The form to which the above relates to is attached and viewing it would help you understand what I mean.


I have already thought of a way to use multi-dimensional variant arrays to store data week by week, which, although I have not yet written the code for, I imagine would be fairly easy to accomplish.

My problem is that I have just purchased one of Microsoft's books on Visual Basic, "Programming Visual Basic 6.0" written by Francesco Balena, which has given me a completely alternative approach on how to deal with the week by week data.

It must be mentioned that although my original method I presume will work fine, MOST of the data (i.e. text boxes if you view my form )for each week will be left blank which is a waste of time and will slow down my application down.

Francesco Balena mentions in his book that an array can also hold an additional array (see page 177, if you have the book, "Arrays of arrays") saving memory for the application.

My original method is to basically create a multi-dimensional array, collecting ALL data for each week, including those which are NIL. A ROUGH example is as follows:

arr(wkNo,DayNo,ReceiptType,)    'ReceiptType as integer
arr(wkNo,ExpenseType)    'ExpenseType as integer

As I mentioned, there will be a lot of memory wasted with this type of array as not every different type of expense will be encountered each week. (I.e. once the array has been created during run-time, there will be a fixed number of entries for each dimension)

Francesco's book mentions an array that can hold an additional array, a sub-array. Something that looks like arr(1)(2) for example.

Although I can roughly grasp the method in particular, I am trying to find out a way how I can create a "sub-array" to deal with the week by week expenses so that they can be stored as need be, but when there is no data to save, then no sub-array is created.

Sorry if the above sounds confusing, but I can't think of any better way to describe what's going on! Like I said, have a look at the attached form!

IF Does Not Equal 0
I have the following formula =IF(C27+C28+C29-C45=0,"YES","NO")), The figures in the cells are this. C27=55,492.67 C28=942.24 C29=4203.49 C45=60,638.40. Now the formula answer is giving me a "No" when it should be "Yes". I have the same formula in different cells and it gives me a "Yes". I have formatted all the cells the same and even tried the Round function and I still get a "No" when the sum of those cells - C45 does equal 0. Any help on what the problem could be?

Why Does This Equal 1?
I don't understand why the second TestNumber equals 1


Code:
Dim TestString As String = "the quick brown fox jumps over the lazy dog"
Dim TestNumber As Integer
' Returns 32.
TestNumber = InStrRev(TestString, "the")
' Returns 1.
TestNumber = InStrRev(TestString, "the", 16)

IF NOT Equal.
Hi.. im sorry but i couldnt search for this code.. becoz it contains the word 'not'.. this is what i want to do:


Code:
If text1.text is not equal to "" then
'do somthing
Else
'Do something
End If

How is the 'not equal' represented?

Not Equal To
How do you say "not equal to"
ex: if txtBox is (not equal to) then

I tried the <> and I don't think that it worked.
then I tried != an I keep getting an error "Expected then or goto"

Any ideas?

Does Not Equal
How do you do does not equal

for example:

If A doesnotequal 3 then
blah blah

I thought it might be =! but that doesn't work.

Does Not Equal
I know how to say:

If form1.backcolor = H8000 then blah blah

but how do u say if form1.backcolor does NOT equal?

thx

1 Not Equal To 1
In what case would not 1 not equal 1?
Here is what is going on I have a check amount that equals a transaction amount if they are equal then the code goes thru a process. The problem is that

VB Code:
dblCheckAmount = 100.00strTranAmount = "-100.00" if dblCheckAmount = Val(strTranAmount) * -1 then    blah,blahend if


Sometimes this does go into the blah blah stuff?

Ideas? Solutions?

What I have done I use FormatNumber on the two variables. And that seems to be working.

Not Equal To
hi i want to do this statement

if text1.text is not "" then
run code here

Does Not Equal
ok i have a questions its been a long time and i havent been using my vb and i for got is there a symbol for "Does Not Equal" and if so what is it



thanks in advanced

Not Equal To
what is the not equal to symbol in VB? I forget..in C++ it's !=

PP VB Text Box To Equal Another
Dear All,

In Powerpoint how can i get a text box on the same slide to equal the text in another.

To lay it out - on the top of the slide is the slide title. I also want this title to be displayed on the vertical axis in another text box. Rather than having to copy and paste all the time, I need to try an automate this.

Thanks
Robin

REEEALLY Equal
One of my co-workers is using Excel and she asked me if there's a way that she can add a function that's more of a copy than the '=' so that if she has "The last word of this line should be <font color=red>red</font color=red>." in one cell, then she can copy the text AND exact formatting to the other cell.

I wasn't sure how to go about doing this. Anyone have any ideas?


"The LORD is my strength and my shield" - Psalms 28:7

When To Set Objects Equal To Nothing
I often see on complicated macros that the programmer has taken the time to set his objects equal to nothing at the end of the macro, in order to avoid tying up unnecessary system resources.

To which objects does this apply? When I set ranges during a macro, do I need to worry about setting them to nothing at the end? How about DataObjects? What about if I use late binding to open an instance of Word using Excel VBA?

I canít seem to find much on this topic in the documentation.

'Not Equal To' Method
Hi I am trying to write some code to loop until the cell in question is not equal to 'deleted', any suggestions?

Any help would be greatly appreciated.

Closest But Less Than Or Equal To
Is there a function or a way to find the smallest variable in a group of variables? The variables are declared as Single.

SQL: How To Link When A Is Not Equal To B
Hye,

Need your help in creating an sql statement to be used in vb. The scenerio is that I have to find data that contains in one table but not in another. Namely A and B. I need to display B data which not contains in A. But the problem is that A is not equal to B. the data in A is something like this, "WO1234" and B is "SR1234". They have the same back number basically and I have to compare this back number. How can I compare them both when I dont know how to link A with B. And how can the query be? Please help!!!!!

Work done so far:

Select a.p_number, b.d_number from A a, B b where a.p_number is null and a.p_number = b.d_number.

But no rows are selected because a.p_number is not equal with b.d_number in the front character.

How To Stop Equal
hi all,

i creat calculator by vb....

but i need ur help to tell my how i can prevent equal button from doubling the result
i tried hard to figure the solution..but i fall

to illustrate my qustion, when i click the equal button it give me a right answer BUT if i click on it again its give me another answer

i need it to give my ONLY one answer


so can u help me..and i will be thankful

really i need the answer for the next few houre to sumbit my report.


this is my code:-


Code:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim total1 As Integer
Dim total2 As Integer
Dim clearDisplay As Boolean
Dim Operand1 As Double, Operand2 As Double
Dim [Operator] As String

Private Sub command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPlus.Click
total1 = total2 + Val(txtDisplay.Text)
Operand1 = total1 'Val(txtDisplay.Text)
[Operator] = "+"
txtDisplay.Text = txtDisplay.Text & cmdPlus.Text
clearDisplay = True
txtDisplay.Clear()

End Sub

Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click

txtDisplay.Text = txtDisplay.Text & btn0.Text

End Sub

Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
txtDisplay.Text = txtDisplay.Text & btn1.Text
End Sub

Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
txtDisplay.Text = txtDisplay.Text & btn2.Text
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
txtDisplay.Text = txtDisplay.Text & btn3.Text
End Sub
Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
txtDisplay.Text = txtDisplay.Text & btn4.Text
End Sub

Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
txtDisplay.Text = txtDisplay.Text & btn5.Text
End Sub

Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
txtDisplay.Text = txtDisplay.Text & btn6.Text
End Sub

Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
txtDisplay.Text = txtDisplay.Text & btn7.Text
End Sub

Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
txtDisplay.Text = txtDisplay.Text & btn8.Text
End Sub

Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
txtDisplay.Text = txtDisplay.Text & btn9.Text
End Sub

Private Sub cmdClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClear.Click
txtDisplay.Text = ""

End Sub

Private Sub command2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEquals.Click

Dim result As Double

Operand2 = Val(txtDisplay.Text)
Try
Select Case [Operator]
Case "+"
result = Operand1 + Operand2
End Select
Finally
txtDisplay.Text = result
clearDisplay = True

End Try
End Sub


End Class


plz help meee

Set List Equal To Another
Hey, how could I set a list equal to another one? So it contains all of the same items? Thanks

If Statements - Not Equal To?
Well, I tried to google my question, but didn't get any results. How can I use if statments to check if the value is not 0 or not 1?

How To Make A Not Equal?
I'm trying to make it so if text1.text (is not equal) to text2.text ...

Just trying to figure out how to make it not equal. Maybe -= or something?

VB Syntax For Does Not Equal To?
VB Code:
If strTest "doesnt equal" 5 ThenTextbox1 = "Man I suck at this."

What's The 'does Not Equal' Sign!!?!?!?!???
lol, having not used vb for a while, i've become very rusty.

i'm used to using the != sign in php, but this doesnt seem to work in vb. what's it's equivalent?

Question About Not Equal To
I have looked at some code where people place data inside of the not equal to operator. It looks something like this:

If txtQuantity <strName> Then

I am pulling that from memory so it may be incomplete. But the question at hand is what is the point of putting data inside of the greater than and the less than symbols?

Whats 'does Nor Equal' In Vb ?
Like in C++ its != whats it in VB ?

thanks.

'Not Equal To' Method
Hi I am trying to write some code to loop until the cell in question is not equal to 'deleted', any suggestions?

Any help would be greatly appreciated.

Setting One UDT Equal To Another
i have a UDT that contains a class, and i want to know if i set one equal to another, will it copy all the member data of the UDT, including the class?

Doesnt Equal..
How do you do If Something DOESNOTEQUAL something... E.g. My guess would be 'If Something != Something then' ..But that apparently doesnt work .....P.S...We are comparing strings

Vb5 Equal For Split?
I believe the split function is new to vb6, but a friend of mine has vb5 so I want to use code that will work with vb5 so what is the code i can use in vb5 to split a textfile up at the commas and add them to an array?

Not Equal To A Number
How do I say

if string1 <> a number

Same Values Not Equal
When I run the listed code, values A and B appear to have the same value.
I try ?a and ?b and they are the same. hex values are the same. but logic says not equal. Also, if I subtract I get a value like
-1.45519152283669E-11

If I change double to currency, it works.

Two questions.
1.) Why the difference?
2.) How can I view the real value that is stored in A and B?


Code:
Private Sub Command1_Click()
    
    Dim A As Double
    Dim B As Double

    A = 111123.51
    B = 111122.41
    
    B = B + 1.1
    If A = B Then
        MsgBox "="
    Else
        MsgBox "<>"
    End If



End Sub





Edited by - ShrimperDan on 6/22/2005 8:58:46 AM

Why Does This Equal Zero For Every Year
*** Problem Fixed ***

I changed it to:
Code:Private Sub cmdCalculate_Click()
    intRisingYear = 1
    sngInterest = Val(txtInterest)
    sngRisingBalance = Val(txtBalance)
    intMaximumYears = Val(txtMaximumYears)
    For intYear = 1 To intMaximumYears Step 1
    sngRisingBalance = sngRisingBalance * sngInterest + sngRisingBalance
    picOutput.Print "Value After "; intRisingYear; "Years = " _
            ; sngRisingBalance
    intRisingYear = intRisingYear + 1
    Next intYear
End Sub

I'm trying to use a For Loop to calculate compounded interest for X number of years and print the result to picOutput.

Why does this equal zero for every year

Please tell me why and how to fix it

Code:
Dim sngBal As Single, sngInterest As Single, _
    intYears As Integer, sngRisingBalance As Single, _
    intYear As Integer, intRisingYear As Integer

Private Sub cmdCalculate_Click()
    intRisingYear = 1
    sngInterest = Val(txtInterest)
    sngBal = Val(txtBalance)
    intYears = Val(txtMaximumYears)
    For intYear = 1 To intYears Step 1
    sngRisingBalance = sngRisingBalance * sngInterest + sngRisingBalance
    picOutput.Print "Value After "; intRisingYear; "Years = " _
            ; sngRisingBalance
    intRisingYear = intRisingYear + 1
    Next intYear
End Sub





Edited by - webmanoffesto on 10/5/2003 7:14:59 AM

Not Equal To Symbol
Hi,

Do anyone know what is the symbol for not equal to in VB.
What I mean is that I want to make sure that the user enter the valid text in the textbox. If the text is not valid type by the user, msgbox will pop up to ask the user to type again the text.

Thanks

Object Is Equal To Nothing
In ASP I have a object call objtemp.
I have a function that return stuff to the object. Sometimes the function doesn't return anything. I need a way to check the obj for NOTHING. I tried using if objtemp = NOTHING and
If objtemp = "Nothing" and I even tried the IsEmpty method. Is there a way for this???
Thank You

Have Project Look Equal On All Computers
What I am trying to do is keep the "aspect ratio" or something like that fluent on my Project throughout all computers.

The problem is, when I transfer my Project exe file from Windows XP (where I made the file) to my Windows 98 the file looks all messed up. I have jpeg's of the examples.

"Original File in VB.jpeg" is a picture of what my VB Project exe looks like on Windows XP, perfect.(the image file stretched or not, looks the same)

"Not Stretched.jpeg" is a picture of my project on windows 98. The image file is not stretched and the textbox is not the same width as the image, as in the first jpeg from Windows XP (like I want it to be).

"Stretched.jpeg" is a picture of my project on windows 98. The image file is stretched and the width's and every aspect is the same, but the form itself is too big and the image file is stretched and looks horrible.

What I want is the other things on the form to "de-stretch", like the textbox decrease it's width to match the image, and the form itself decrease to center the image on the form.

So my question is, is there any way to like say "keep aspect ratio" or something like that on the form so it looks the same on all computers. So I can give it to all my friends who have different computers.

Thanks, sorry for the long paragraph, it was the best way i could explain it. If you have any questions let me know.

HOw To Make A Column Equal To A Row
how do u make a column equal to a row? I try to copy and paste but it doesnt do it right

Finding Out If Variable Is Equal To Nothing
dim ObjectName as RichTextBox

If ObjectName = Nothing then
[do this]
endif


The above doesn't work.
What is the correct way to see if ObjectName has been Set to anything?

Thanks,
John

Sorry For This Question But I Really Dont Know How To Know 800*600 Equal ? ....
in properties form height and width is over 800*600 is not pixel ... right ? and if i want to set it to 800*600 what numeric i should add ?

What Is The Fastest Way To Tell If One File Is Equal To Another?
Anyone know?
Id assume the first check would be to just see if the filesizes are the same, and if they are.. then what? Should I do a CRC32 checksum? Or just load the data of the files into 2 strings and see if they are the same? What is the fastest way to do so?

How Can One Number Equal 2 In LEN Function???
Hello all,

This is the dumbest thing i've ever seen. I'm trying to see if a number's length is 1 or 2, and doing something from that, but it is messed up.


Look at my attached screen shots, it says "7" in the LEN function = 2


What the heck??

Are All DLLs Created Equal?
Can someone explain how a dll works? What I'm wondering is if you can access the functions in any dll ie. those NOT created in VB6. Am I correct in thinking that not all dlls are the same?
If I look in the Project, References window I see a long list of files -some of which are dlls. I know these dlls have been registered with the system but you can't register any dll -correct?
And if not, what differentiates a registered from a non-registerable dll?
For the ones that can't be registered, is it possible from VB6 to access any of it's 'functions'? Are there utilities that can list dll functions?

Sorry for so many questions in a row but just had a bit of a brainstorm happen.

Setting List Equal To Another
Is there a way I can set one listview equal to another? For example
VB Code:
ListView(1) = ListView(0)

The Equal Button On My Calculator.
I'm back, with another calculator question.

How do I tell my equals button if i'm trying to add, subtract, divide or multiply my two numbers?

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