Search the web
Sign In
New User? Sign Up
helpwithvb · A group for those who need help with Visual Basic
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 22565 - 22594 of 22756   Newest  |  < Newer  |  Older >  |  Oldest
Messages: Show Message Summaries   (Group by Topic) Sort by Date v  
#22594 From: "Timothy Rupp" <tim.rupp@...>
Date: Tue Nov 17, 2009 1:16 am
Subject: RE: Re: More on Excel
timrupp804
Offline Offline
Send Email Send Email
 

You have added the element to the array but have not assigned anything to that element…it’s still null.

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of seecwriter
Sent: Monday, November 16, 2009 4:32 PM
To: helpwithvb@yahoogroups.com
Subject: [helpwithvb] Re: More on Excel

 

 

If I have two elements why does accessing the 2nd element throw a Null pointer exception?

Also, if I just have the declaration "Dim MyString() as String" and try to access MyString(0), that too will throw an exception. I don't have one element.

--- In helpwithvb@yahoogroups.com, "Timothy Rupp" <tim.rupp@...> wrote:
>
> You ReDim. So now you have two elements and upper bound is correctly 1. (You
> have elements 0 and 1.) If you break before ReDim, you should have upper
> bound of 0.
>
>
>
> Console.WriteLine writes a line to the console window. If you're not running
> in console mode you won't see anything. I use console mode rather than
> Windows apps to test concepts and modules. No form overhead that way.
>
>
>
> From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On
> Behalf Of seecwriter
> Sent: Monday, November 16, 2009 2:59 PM
> To: helpwithvb@yahoogroups.com
> Subject: [helpwithvb] Re: More on Excel
>
>
>
>
>
> Your example below works as you describe. GetUpperBound does return a 2 when
> there are 3-elements in the array.
>
> My case is slightly different.
>
> Dim MyStrings() as String
> Dim numStrings as Integer
>
> ReDim MyString(1)
>
> numStrings = MyString.GetUpperBound(0)
>
> Print numStrings in the Immediate Window and it will be 1. I contend it
> should be 0, unless I did something wrong.
>
> What I've done in my application is to subtract 1 from the result of
> GetUpperBound, and this seems to have solved my problem.
>
> (FYI...I don't know where Console.Writeline... is supposed to write, but it
> doesn't show up on my screen.)
>
> --- In helpwithvb@yahoogroups.com <mailto:helpwithvb%40yahoogroups.com> ,
> "Timothy Rupp" <tim.rupp@> wrote:
> >
> > Where do you actually load the array?
> >
> >
> >
> > If you have an upper bound of 2 you have three elements f(0), f(1), and
> > f(2).
> >
> >
> >
> > Try it here:
> >
> >
> >
> > Sub Main()
> >
> >
> >
> > Dim myArray(2) As String
> >
> > myArray(0) = "string1"
> >
> > myArray(1) = "string2"
> >
> > myArray(2) = "string3"
> >
> >
> >
> > Dim uBound As Integer
> >
> > uBound = myArray.GetUpperBound(0)
> >
> >
> >
> > Console.WriteLine("myArray(0) = " & myArray(0).ToString)
> >
> > Console.WriteLine("myArray(1) = " & myArray(1).ToString)
> >
> > Console.WriteLine("myArray(2) = " & myArray(2).ToString)
> >
> > Console.WriteLine("UpperBound = " & uBound.ToString)
> >
> > Console.ReadLine()
> >
> >
> >
> > End Sub
> >
> >
> >
> > What is the exception you get?
> >
> >
> >
> >
> >
> >
> >
> > From: helpwithvb@yahoogroups.com <mailto:helpwithvb%40yahoogroups.com>
> [mailto:helpwithvb@yahoogroups.com <mailto:helpwithvb%40yahoogroups.com> ]
> On
> > Behalf Of seecwriter
> > Sent: Friday, November 13, 2009 2:27 PM
> > To: helpwithvb@yahoogroups.com <mailto:helpwithvb%40yahoogroups.com>
> > Subject: [helpwithvb] More on Excel
> >
> >
> >
> >
> >
> > Given a one-dimensional array of strings, f(), that has 2 strings.
> > Does it make sense that the Upperbound index is 2?
> >
> > Dim f() as String 'Assume 2-strings
> >
> > Dim index as Integer
> >
> > index = f.GetUpperBound(0) ' Index = 2
> >
> > I would have expected 1, giving me f(0) and f(1). But Nooooooo! It gives
> me
> > 2. And when I try to use f(2) it throws an exception. So really, the value
> > returned by GetUpperBound is not the highest index of the array, its the
> > number of strings in the array. More false advertising.
> >
>


#22593 From: "seecwriter" <seecwriter@...>
Date: Mon Nov 16, 2009 10:30 pm
Subject: Re: Excel
seecwriter
Offline Offline
Send Email Send Email
 
I will answer my own question. The constants for dot Net have been put into
enums, or the equivalent. So you have to qualify the constant with a longer
path.
For example, to use constant xlDiagonalDown, requires the following change:

XlBordersIndex.xlDiagonalDown

So, you're thinking problem solved. You'd be Wrong! It turns out that some of
the constant names used in VB6 and in Excel 2003 have been changed for the dot
Net version. Makes sense to me. NOT!

For example, in VB6 and in Excel 2003, to set the thickness of a cell's border
you could assign it either xlThin, xlThick, or xlNone. But in dot there these
constant names are not even used anymore. Instead there there is
xlLineStyleLineNone, and xlDash, xlDashDot, etc. But there is no xlThin or
xlThick. So what I did is, I got the integer value from VB6 and used that. Crude
but effective.


--- In helpwithvb@yahoogroups.com, "seecwriter" <seecwriter@...> wrote:
>
> Creating macros in Excel and then using the VBA code into my VB6 application
worked great.
> But when I move to .Net, the constants used (see below) in Excel are no longer
recognized.
> I did a search on MSDN for Excel VBA, and in the examples for Excel 2007, it
used some of the same constants. So am I missing an Import or something? This is
what I use:
>
> Imports Microsoft.Office.Interop
> Imports Microsoft.Office.Interop.Excel
>
> For example, in this line, xlNone and xlDiagonalDown are flagged as not
declared.
>
> oXL.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
>
>
> Constants:
>
> xlNone
> xlCenter
> xlDiagonalDown
> xlDiagonalUp
> xlEdgeLeft
> xlContinuous
> xlThick
> xlThin
> xlAutomatic
> xlEdgeTop
> xlEdgeBottom
> xlEdgeRight
> xlInsideVertical
>

#22592 From: "seecwriter" <seecwriter@...>
Date: Mon Nov 16, 2009 9:31 pm
Subject: Re: More on Excel
seecwriter
Offline Offline
Send Email Send Email
 
If I have two elements why does accessing the 2nd element throw a Null pointer
exception?

Also, if I just have the declaration "Dim MyString() as String" and try to
access MyString(0), that too will throw an exception. I don't have one element.

--- In helpwithvb@yahoogroups.com, "Timothy Rupp" <tim.rupp@...> wrote:
>
> You ReDim. So now you have two elements and upper bound is correctly 1. (You
> have elements 0 and 1.) If you break before ReDim, you should have upper
> bound of 0.
>
>
>
> Console.WriteLine writes a line to the console window. If you're not running
> in console mode you won't see anything. I use console mode rather than
> Windows apps to test concepts and modules. No form overhead that way.
>
>
>
> From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On
> Behalf Of seecwriter
> Sent: Monday, November 16, 2009 2:59 PM
> To: helpwithvb@yahoogroups.com
> Subject: [helpwithvb] Re: More on Excel
>
>
>
>
>
> Your example below works as you describe. GetUpperBound does return a 2 when
> there are 3-elements in the array.
>
> My case is slightly different.
>
> Dim MyStrings() as String
> Dim numStrings as Integer
>
> ReDim MyString(1)
>
> numStrings = MyString.GetUpperBound(0)
>
> Print numStrings in the Immediate Window and it will be 1. I contend it
> should be 0, unless I did something wrong.
>
> What I've done in my application is to subtract 1 from the result of
> GetUpperBound, and this seems to have solved my problem.
>
> (FYI...I don't know where Console.Writeline... is supposed to write, but it
> doesn't show up on my screen.)
>
> --- In helpwithvb@yahoogroups.com <mailto:helpwithvb%40yahoogroups.com> ,
> "Timothy Rupp" <tim.rupp@> wrote:
> >
> > Where do you actually load the array?
> >
> >
> >
> > If you have an upper bound of 2 you have three elements f(0), f(1), and
> > f(2).
> >
> >
> >
> > Try it here:
> >
> >
> >
> > Sub Main()
> >
> >
> >
> > Dim myArray(2) As String
> >
> > myArray(0) = "string1"
> >
> > myArray(1) = "string2"
> >
> > myArray(2) = "string3"
> >
> >
> >
> > Dim uBound As Integer
> >
> > uBound = myArray.GetUpperBound(0)
> >
> >
> >
> > Console.WriteLine("myArray(0) = " & myArray(0).ToString)
> >
> > Console.WriteLine("myArray(1) = " & myArray(1).ToString)
> >
> > Console.WriteLine("myArray(2) = " & myArray(2).ToString)
> >
> > Console.WriteLine("UpperBound = " & uBound.ToString)
> >
> > Console.ReadLine()
> >
> >
> >
> > End Sub
> >
> >
> >
> > What is the exception you get?
> >
> >
> >
> >
> >
> >
> >
> > From: helpwithvb@yahoogroups.com <mailto:helpwithvb%40yahoogroups.com>
> [mailto:helpwithvb@yahoogroups.com <mailto:helpwithvb%40yahoogroups.com> ]
> On
> > Behalf Of seecwriter
> > Sent: Friday, November 13, 2009 2:27 PM
> > To: helpwithvb@yahoogroups.com <mailto:helpwithvb%40yahoogroups.com>
> > Subject: [helpwithvb] More on Excel
> >
> >
> >
> >
> >
> > Given a one-dimensional array of strings, f(), that has 2 strings.
> > Does it make sense that the Upperbound index is 2?
> >
> > Dim f() as String 'Assume 2-strings
> >
> > Dim index as Integer
> >
> > index = f.GetUpperBound(0) ' Index = 2
> >
> > I would have expected 1, giving me f(0) and f(1). But Nooooooo! It gives
> me
> > 2. And when I try to use f(2) it throws an exception. So really, the value
> > returned by GetUpperBound is not the highest index of the array, its the
> > number of strings in the array. More false advertising.
> >
>

#22591 From: "Timothy Rupp" <tim.rupp@...>
Date: Mon Nov 16, 2009 8:58 pm
Subject: RE: Re: More on Excel
timrupp804
Offline Offline
Send Email Send Email
 

You ReDim. So now you have two elements and upper bound is correctly 1. (You have elements 0 and 1.) If you break before ReDim, you should have upper bound of 0.

 

Console.WriteLine writes a line to the console window. If you’re not running in console mode you won’t see anything. I use console mode rather than Windows apps to test concepts and modules. No form overhead that way.

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of seecwriter
Sent: Monday, November 16, 2009 2:59 PM
To: helpwithvb@yahoogroups.com
Subject: [helpwithvb] Re: More on Excel

 

 

Your example below works as you describe. GetUpperBound does return a 2 when there are 3-elements in the array.

My case is slightly different.

Dim MyStrings() as String
Dim numStrings as Integer

ReDim MyString(1)

numStrings = MyString.GetUpperBound(0)

Print numStrings in the Immediate Window and it will be 1. I contend it should be 0, unless I did something wrong.

What I've done in my application is to subtract 1 from the result of GetUpperBound, and this seems to have solved my problem.

(FYI...I don't know where Console.Writeline... is supposed to write, but it doesn't show up on my screen.)

--- In helpwithvb@yahoogroups.com, "Timothy Rupp" <tim.rupp@...> wrote:
>
> Where do you actually load the array?
>
>
>
> If you have an upper bound of 2 you have three elements f(0), f(1), and
> f(2).
>
>
>
> Try it here:
>
>
>
> Sub Main()
>
>
>
> Dim myArray(2) As String
>
> myArray(0) = "string1"
>
> myArray(1) = "string2"
>
> myArray(2) = "string3"
>
>
>
> Dim uBound As Integer
>
> uBound = myArray.GetUpperBound(0)
>
>
>
> Console.WriteLine("myArray(0) = " & myArray(0).ToString)
>
> Console.WriteLine("myArray(1) = " & myArray(1).ToString)
>
> Console.WriteLine("myArray(2) = " & myArray(2).ToString)
>
> Console.WriteLine("UpperBound = " & uBound.ToString)
>
> Console.ReadLine()
>
>
>
> End Sub
>
>
>
> What is the exception you get?
>
>
>
>
>
>
>
> From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On
> Behalf Of seecwriter
> Sent: Friday, November 13, 2009 2:27 PM
> To: helpwithvb@yahoogroups.com
> Subject: [helpwithvb] More on Excel
>
>
>
>
>
> Given a one-dimensional array of strings, f(), that has 2 strings.
> Does it make sense that the Upperbound index is 2?
>
> Dim f() as String 'Assume 2-strings
>
> Dim index as Integer
>
> index = f.GetUpperBound(0) ' Index = 2
>
> I would have expected 1, giving me f(0) and f(1). But Nooooooo! It gives me
> 2. And when I try to use f(2) it throws an exception. So really, the value
> returned by GetUpperBound is not the highest index of the array, its the
> number of strings in the array. More false advertising.
>


#22590 From: "seecwriter" <seecwriter@...>
Date: Mon Nov 16, 2009 7:59 pm
Subject: Re: More on Excel
seecwriter
Offline Offline
Send Email Send Email
 
Your example below works as you describe. GetUpperBound does return a 2 when
there are 3-elements in the array.

My case is slightly different.

Dim MyStrings() as String
Dim numStrings as Integer

ReDim MyString(1)

numStrings = MyString.GetUpperBound(0)

Print numStrings in the Immediate Window and it will be 1. I contend it should
be 0, unless I did something wrong.

What I've done in my application is to subtract 1 from the result of
GetUpperBound, and this seems to have solved my problem.

(FYI...I don't know where Console.Writeline... is supposed to write, but it
doesn't show up on my screen.)


--- In helpwithvb@yahoogroups.com, "Timothy Rupp" <tim.rupp@...> wrote:
>
> Where do you actually load the array?
>
>
>
> If you have an upper bound of 2 you have three elements f(0), f(1), and
> f(2).
>
>
>
> Try it here:
>
>
>
> Sub Main()
>
>
>
>         Dim myArray(2) As String
>
>         myArray(0) = "string1"
>
>         myArray(1) = "string2"
>
>         myArray(2) = "string3"
>
>
>
>         Dim uBound As Integer
>
>         uBound = myArray.GetUpperBound(0)
>
>
>
>         Console.WriteLine("myArray(0) = " & myArray(0).ToString)
>
>         Console.WriteLine("myArray(1) = " & myArray(1).ToString)
>
>         Console.WriteLine("myArray(2) = " & myArray(2).ToString)
>
>         Console.WriteLine("UpperBound = " & uBound.ToString)
>
>         Console.ReadLine()
>
>
>
>     End Sub
>
>
>
> What is the exception you get?
>
>
>
>
>
>
>
> From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On
> Behalf Of seecwriter
> Sent: Friday, November 13, 2009 2:27 PM
> To: helpwithvb@yahoogroups.com
> Subject: [helpwithvb] More on Excel
>
>
>
>
>
> Given a one-dimensional array of strings, f(), that has 2 strings.
> Does it make sense that the Upperbound index is 2?
>
> Dim f() as String 'Assume 2-strings
>
> Dim index as Integer
>
> index = f.GetUpperBound(0) ' Index = 2
>
> I would have expected 1, giving me f(0) and f(1). But Nooooooo! It gives me
> 2. And when I try to use f(2) it throws an exception. So really, the value
> returned by GetUpperBound is not the highest index of the array, its the
> number of strings in the array. More false advertising.
>

#22589 From: "Steve Manser" <smanser@...>
Date: Sun Nov 15, 2009 5:34 pm
Subject: VB dot Net Array [ Was: More on Excel ]
tileguy2929
Offline Offline
Send Email Send Email
 
This is just, pretty much,
an FYI for me as I re-watch Tiger  :)

This threw me a curve-ball when
I first looked at the lines of code.

Not being that familiar with the many
ways we can do things in the improved
new language(s) of Net, I began to suspect
that there was a new thingie...

Imports System.DimensionArray.ReadMyMind

>> Dim f() as String 'Assume 2-strings

No, I don't think so.
The array is dynamic, and can be sized using ReDim.

ReDim f(1) As String

..would now give us an array with 2 elements.

Dim f(2) as String

This line of code creates a string array
whose dimensions are zero to two, or 3 elements.

In this case, GetUpperBound() would properly give us '2'

http://www.vb-helper.com/howto_net_declare_arrays.html

This is interesting:
http://www.vb-helper.com/tip_net_empty_array.html

<quote>

In VB .NET, you cannot use an array's properties and
methods until you instantiate it. For example, the
following code declares an array.

The two Debug.WriteLine statements that follow
fail because the array has not been created.

     Dim values() As Integer
     Debug.WriteLine(values.Length)
     Debug.WriteLine(values.GetLowerBound(0))

You can see if the array is Nothing
to tell if it has been created yet.

Sometimes, however, the code would be more consistent
if you could use Length, GetLowerBound, and GetUpperBound
to loop over the empty array. You can do that if you use
the following statement to allocate the array
with no items in it.

     Dim values(-1) As Integer

Now the array exists, Length returns 0,
GetLowerBound returns 0, and GetUpperBound returns -1.

</quote>

Good Fun this dot Net, and the more I poke around
it certainly does seem to make a great many tasks
much easier than what we had to do in Classic VB-6.

________________________________

From: helpwithvb@yahoogroups.com
On Behalf Of seecwriter
Sent: Friday, November 13, 2009 2:27 PM
To: helpwithvb@yahoogroups.com
Subject: [helpwithvb] More on Excel


Given a one-dimensional array of strings,
f(), that has 2 strings.

Does it make sense that the Upperbound index is 2 ?

Dim f() as String 'Assume 2-strings

Dim index as Integer

index = f.GetUpperBound(0) ' Index = 2

I would have expected 1, giving me f(0) and f(1).
But Nooooooo! It gives me 2. And when I try to use f(2)
it throws an exception. So really, the value returned by
GetUpperBound is not the highest index of the array,
its the number of strings in the array.

More false advertising.

..
.

#22588 From: "Timothy Rupp" <tim.rupp@...>
Date: Sat Nov 14, 2009 1:00 am
Subject: RE: More on Excel
timrupp804
Offline Offline
Send Email Send Email
 

Where do you actually load the array?

 

If you have an upper bound of 2 you have three elements f(0), f(1), and f(2).

 

Try it here: 

 

Sub Main()

 

        Dim myArray(2) As String

        myArray(0) = "string1"

        myArray(1) = "string2"

        myArray(2) = "string3"

 

        Dim uBound As Integer

        uBound = myArray.GetUpperBound(0)

 

        Console.WriteLine("myArray(0) = " & myArray(0).ToString)

        Console.WriteLine("myArray(1) = " & myArray(1).ToString)

        Console.WriteLine("myArray(2) = " & myArray(2).ToString)

        Console.WriteLine("UpperBound = " & uBound.ToString)

        Console.ReadLine()

 

    End Sub

 

What is the exception you get? 

 

 

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of seecwriter
Sent: Friday, November 13, 2009 2:27 PM
To: helpwithvb@yahoogroups.com
Subject: [helpwithvb] More on Excel

 

 

Given a one-dimensional array of strings, f(), that has 2 strings.
Does it make sense that the Upperbound index is 2?

Dim f() as String 'Assume 2-strings

Dim index as Integer

index = f.GetUpperBound(0) ' Index = 2

I would have expected 1, giving me f(0) and f(1). But Nooooooo! It gives me 2. And when I try to use f(2) it throws an exception. So really, the value returned by GetUpperBound is not the highest index of the array, its the number of strings in the array. More false advertising.


#22587 From: "seecwriter" <seecwriter@...>
Date: Fri Nov 13, 2009 7:27 pm
Subject: More on Excel
seecwriter
Offline Offline
Send Email Send Email
 
Given a one-dimensional array of strings, f(), that has 2 strings.
Does it make sense that the Upperbound index is 2?

Dim f() as String     'Assume 2-strings

Dim index as Integer

index = f.GetUpperBound(0)  ' Index = 2

I would have expected 1, giving me f(0) and f(1). But Nooooooo! It gives me 2.
And when I try to use f(2) it throws an exception. So really, the value returned
by GetUpperBound is not the highest index of the array, its the number of
strings in the array. More false advertising.

#22586 From: "seecwriter" <seecwriter@...>
Date: Fri Nov 13, 2009 5:46 pm
Subject: Excel
seecwriter
Offline Offline
Send Email Send Email
 
Creating macros in Excel and then using the VBA code into my VB6 application
worked great.
But when I move to .Net, the constants used (see below) in Excel are no longer
recognized.
I did a search on MSDN for Excel VBA, and in the examples for Excel 2007, it
used some of the same constants. So am I missing an Import or something? This is
what I use:

Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Excel

For example, in this line, xlNone and xlDiagonalDown are flagged as not
declared.

oXL.Selection.Borders(xlDiagonalDown).LineStyle = xlNone


Constants:

xlNone
xlCenter
xlDiagonalDown
xlDiagonalUp
xlEdgeLeft
xlContinuous
xlThick
xlThin
xlAutomatic
xlEdgeTop
xlEdgeBottom
xlEdgeRight
xlInsideVertical

#22585 From: "allan_blackford" <allan_blackford@...>
Date: Fri Nov 13, 2009 1:46 am
Subject: Cell application
allan_blackford
Offline Offline
Send Email Send Email
 
I'm thinking about writing a cell phone application that would, via blue tooth,
upload something like a text file to a pc, which could then be imported into an
application that I am in the early stages of designing.      I'm not sure which
language to use.  I've never done a cell phone application before.  I'm
wondering if I used c# or vb for  the mobile application, if I wouldn't be
limiting myself to only smart phones.  I assume that most every phone, including
smart phones, support java.  Also, wondering if anyone has a good site or info.
to share on writing mobile applications.

#22584 From: "Joe Wasko" <jpw@...>
Date: Thu Nov 12, 2009 3:54 pm
Subject: Serial ActiveX for Excel
jpwswbug
Offline Offline
Send Email Send Email
 
Hello everyone,
 
I am trying to find the active X for serial communication for VBA in Excel.  I can add the Version 6 to the collection of tools, but when I try to insert into the user form, It pops up with a message telling me the source cannot be trusted...
 
Have any of you seen or dealt with this?  (Excel 2002 (10.6854.6856) SP 3
 

Joseph Wasko

Pannier Corporation

Software Engineer

P: 412-492-1400 X 314

F: 412-492-1418

jpw@...

www.pannier.com

 

"If you always tell the truth you never have to remember what you said."

 

#22583 From: "Bryan Schulz" <b.schulz@...>
Date: Wed Nov 11, 2009 6:07 am
Subject: Re: ole db code
bryan4772002
Offline Offline
Send Email Send Email
 
hi,
 
so i guess that's a no on the Data Reader way.
i added TreeView1.Nodes.Add(dr(1)) in the while loop and it adds all names to the tree but will check out the dot net ado syntax.

 

Bryan Schulz
----- Original Message -----
Sent: Tuesday, November 10, 2009 11:47 PM
Subject: RE: [helpwithvb] ole db code

 

The DataReader is a stream device. It reads the entire data table. If you were having the results written to the console window you would be able to see all the records written there.

If you have a text box, you will only see the last record that has been read.

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Bryan Schulz
Sent: Wednesday, November 11, 2009 12:18 AM
To: helpwithvb@yahoogroups.com
Subject: Re: [helpwithvb] ole db code

 

ok,

then how do you specify which record is retrieved?

i have a table with name, company, and phone and four records in the table.

the last record is displayed in text boxes when i run;

Private Sub cmdGetName_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdGetName.Click

Dim cnLine As String = String.Empty

Dim strColName As String = String.Empty

cnLine = "Provider=Microsoft.Jet.OLEDB.4.0;"

cnLine = cnLine & " Data Source=C:\rolodex.mdb;"

'provider to be used when working with access database

cn = New OleDbConnection(cnLine)

cn.Open()

cmd = New OleDbCommand("select * from rol_list", cn)

dr = cmd.ExecuteReader

strColName = dr.Getname(1)

MessageBox.Show("column name is: " & strColName)

'expected name field was reported

While dr.Read()

' loading data into TextBoxes by column index

txtRolName.Text = dr(1)

TxtRolCompany.Text = dr(2)

TxtRolPhone.Text = dr(3)

End While

dr.Close()

cn.Close()

End Sub

also, what is the correct syntax to use DR.NextResult?

Bryan Schulz

----- Original Message -----

From: Timothy Rupp

Sent: Tuesday, November 10, 2009 10:30 PM

Subject: RE: [helpwithvb] ole db code

 

The DataReader is a different animal. It is a forward-only stream of data rows from a data source.

You need to call the ExecuteReader method of the OleDbCommand object.

From MSDN:

Public Sub ReadMyData(myConnString As String)

    Dim mySelectQuery As String = "SELECT OrderID, CustomerID FROM Orders"

    Dim myConnection As New OleDbConnection(myConnString)

    Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)

    myConnection.Open()

    Dim myReader As OleDbDataReader

    myReader = myCommand.ExecuteReader()

    ' Always call Read before accessing data.

    While myReader.Read()

        Console.WriteLine(myReader.GetInt32(0).ToString() + ", " _

           + myReader.GetString(1))

    End While

    ' always call Close when done reading.

    myReader.Close()

    ' Close the connection when done with it.

    myConnection.Close()

End Sub

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Bryan Schulz
Sent: Tuesday, November 10, 2009 10:33 PM
To: helpwithvb@yahoogroups.com
Subject: [helpwithvb] ole db code

 

hi,

i am experimenting with adding and retrieving data from an access 4.0 database with ole strings.

Imports System.Data.OleDb

Dim cn As OleDbConnection

Dim cmd As OleDbCommand

Dim dr As OleDbDataReader

i think i read you can use;

dr.NextResult()

to move to the next record

i am used to ado and using the conn.fields("employee name"), conn.movenext to move around and this stuff is greek so how do you specify the field, move next, move previous with this style?

Bryan Schulz


#22582 From: "Timothy Rupp" <tim.rupp@...>
Date: Wed Nov 11, 2009 5:47 am
Subject: RE: ole db code
timrupp804
Offline Offline
Send Email Send Email
 

The DataReader is a stream device. It reads the entire data table. If you were having the results written to the console window you would be able to see all the records written there.

 

If you have a text box, you will only see the last record that has been read.

 

 

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Bryan Schulz
Sent: Wednesday, November 11, 2009 12:18 AM
To: helpwithvb@yahoogroups.com
Subject: Re: [helpwithvb] ole db code

 

 

ok,

then how do you specify which record is retrieved?

i have a table with name, company, and phone and four records in the table.

the last record is displayed in text boxes when i run;

Private Sub cmdGetName_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdGetName.Click

Dim cnLine As String = String.Empty

Dim strColName As String = String.Empty

cnLine = "Provider=Microsoft.Jet.OLEDB.4.0;"

cnLine = cnLine & " Data Source=C:\rolodex.mdb;"

'provider to be used when working with access database

cn = New OleDbConnection(cnLine)

cn.Open()

cmd = New OleDbCommand("select * from rol_list", cn)

dr = cmd.ExecuteReader

strColName = dr.Getname(1)

MessageBox.Show("column name is: " & strColName)

'expected name field was reported

While dr.Read()

' loading data into TextBoxes by column index

txtRolName.Text = dr(1)

TxtRolCompany.Text = dr(2)

TxtRolPhone.Text = dr(3)

End While

dr.Close()

cn.Close()

End Sub

 

also, what is the correct syntax to use DR.NextResult?

 

Bryan Schulz

----- Original Message -----

From: Timothy Rupp

Sent: Tuesday, November 10, 2009 10:30 PM

Subject: RE: [helpwithvb] ole db code

 

 

The DataReader is a different animal. It is a forward-only stream of data rows from a data source.

You need to call the ExecuteReader method of the OleDbCommand object.

From MSDN:

Public Sub ReadMyData(myConnString As String)

    Dim mySelectQuery As String = "SELECT OrderID, CustomerID FROM Orders"

    Dim myConnection As New OleDbConnection(myConnString)

    Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)

    myConnection.Open()

    Dim myReader As OleDbDataReader

    myReader = myCommand.ExecuteReader()

    ' Always call Read before accessing data.

    While myReader.Read()

        Console.WriteLine(myReader.GetInt32(0).ToString() + ", " _

           + myReader.GetString(1))

    End While

    ' always call Close when done reading.

    myReader.Close()

    ' Close the connection when done with it.

    myConnection.Close()

End Sub

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Bryan Schulz
Sent: Tuesday, November 10, 2009 10:33 PM
To: helpwithvb@yahoogroups.com
Subject: [helpwithvb] ole db code

 

hi,

i am experimenting with adding and retrieving data from an access 4.0 database with ole strings.

Imports System.Data.OleDb

Dim cn As OleDbConnection

Dim cmd As OleDbCommand

Dim dr As OleDbDataReader

i think i read you can use;

dr.NextResult()

to move to the next record

i am used to ado and using the conn.fields("employee name"), conn.movenext to move around and this stuff is greek so how do you specify the field, move next, move previous with this style?

Bryan Schulz


#22581 From: "Bryan Schulz" <b.schulz@...>
Date: Wed Nov 11, 2009 5:30 am
Subject: Re: ole db code
bryan4772002
Offline Offline
Send Email Send Email
 
hi,
 
i don't get much explanation from the object browser, f2 and basically only find out what a control or function includes.
should i resort to ado?
i was only trying to learn how to get/send data to a table and eventually load a list of names.
 
Bryan Schulz
 
----- Original Message -----
Sent: Tuesday, November 10, 2009 11:19 PM
Subject: RE: [helpwithvb] ole db code

 

Bryan,

Many of your questions could be answered by a quick check of the Properties and Methods of the Class that you are attempting to use.

Take for instance your question on the dr.NextResult method. The Framework Class Library for the OleDbDataReader Methods shows  “Advances the data reader to the next result, when reading the results of batch SQL statements.” It should be apparent that since you are not working with SQL batches that this method would not be applicable.

Likewise a scan of the methods reveal no way to read previous records and only the Read command that advances the reader to the next record. From this it could be correctly concluded that the OleDbDataReader class is not a random access way of accessing your data.

Take advantage of the tools that are available to you as it will lessen your efforts and smooth the way.

/tr

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Bryan Schulz
Sent: Tuesday, November 10, 2009 10:33 PM
To: helpwithvb@yahoogroups.com
Subject: [helpwithvb] ole db code

 

hi,

i am experimenting with adding and retrieving data from an access 4.0 database with ole strings.

Imports System.Data.OleDb

Dim cn As OleDbConnection

Dim cmd As OleDbCommand

Dim dr As OleDbDataReader

i think i read you can use;

dr.NextResult()

to move to the next record

i am used to ado and using the conn.fields("employee name"), conn.movenext to move around and this stuff is greek so how do you specify the field, move next, move previous with this style?

Bryan Schulz


#22580 From: "Timothy Rupp" <tim.rupp@...>
Date: Wed Nov 11, 2009 5:19 am
Subject: RE: ole db code
timrupp804
Offline Offline
Send Email Send Email
 

Bryan,

 

Many of your questions could be answered by a quick check of the Properties and Methods of the Class that you are attempting to use.

 

Take for instance your question on the dr.NextResult method. The Framework Class Library for the OleDbDataReader Methods shows  “Advances the data reader to the next result, when reading the results of batch SQL statements.” It should be apparent that since you are not working with SQL batches that this method would not be applicable.

 

Likewise a scan of the methods reveal no way to read previous records and only the Read command that advances the reader to the next record. From this it could be correctly concluded that the OleDbDataReader class is not a random access way of accessing your data.

 

Take advantage of the tools that are available to you as it will lessen your efforts and smooth the way.

 

/tr

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Bryan Schulz
Sent: Tuesday, November 10, 2009 10:33 PM
To: helpwithvb@yahoogroups.com
Subject: [helpwithvb] ole db code

 

 

hi,

 

i am experimenting with adding and retrieving data from an access 4.0 database with ole strings.

 

Imports System.Data.OleDb

Dim cn As OleDbConnection

Dim cmd As OleDbCommand

Dim dr As OleDbDataReader

 

i think i read you can use;

dr.NextResult()

to move to the next record

 

i am used to ado and using the conn.fields("employee name"), conn.movenext to move around and this stuff is greek so how do you specify the field, move next, move previous with this style?

 

Bryan Schulz


#22579 From: "Bryan Schulz" <b.schulz@...>
Date: Wed Nov 11, 2009 5:18 am
Subject: Re: ole db code
bryan4772002
Offline Offline
Send Email Send Email
 
ok,
then how do you specify which record is retrieved?
i have a table with name, company, and phone and four records in the table.
the last record is displayed in text boxes when i run;

Private Sub cmdGetName_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdGetName.Click

Dim cnLine As String = String.Empty

Dim strColName As String = String.Empty

cnLine = "Provider=Microsoft.Jet.OLEDB.4.0;"

cnLine = cnLine & " Data Source=C:\rolodex.mdb;"

'provider to be used when working with access database

cn = New OleDbConnection(cnLine)

cn.Open()

cmd = New OleDbCommand("select * from rol_list", cn)

dr = cmd.ExecuteReader

strColName = dr.Getname(1)

MessageBox.Show("column name is: " & strColName)

'expected name field was reported

While dr.Read()

' loading data into TextBoxes by column index

txtRolName.Text = dr(1)

TxtRolCompany.Text = dr(2)

TxtRolPhone.Text = dr(3)

End While

dr.Close()

cn.Close()

End Sub

 
also, what is the correct syntax to use DR.NextResult?
 
Bryan Schulz
----- Original Message -----
Sent: Tuesday, November 10, 2009 10:30 PM
Subject: RE: [helpwithvb] ole db code

 

The DataReader is a different animal. It is a forward-only stream of data rows from a data source.

You need to call the ExecuteReader method of the OleDbCommand object.

From MSDN:

Public Sub ReadMyData(myConnString As String)

    Dim mySelectQuery As String = "SELECT OrderID, CustomerID FROM Orders"

    Dim myConnection As New OleDbConnection(myConnString)

    Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)

    myConnection.Open()

    Dim myReader As OleDbDataReader

    myReader = myCommand.ExecuteReader()

    ' Always call Read before accessing data.

    While myReader.Read()

        Console.WriteLine(myReader.GetInt32(0).ToString() + ", " _

           + myReader.GetString(1))

    End While

    ' always call Close when done reading.

    myReader.Close()

    ' Close the connection when done with it.

    myConnection.Close()

End Sub

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Bryan Schulz
Sent: Tuesday, November 10, 2009 10:33 PM
To: helpwithvb@yahoogroups.com
Subject: [helpwithvb] ole db code

 

hi,

i am experimenting with adding and retrieving data from an access 4.0 database with ole strings.

Imports System.Data.OleDb

Dim cn As OleDbConnection

Dim cmd As OleDbCommand

Dim dr As OleDbDataReader

i think i read you can use;

dr.NextResult()

to move to the next record

i am used to ado and using the conn.fields("employee name"), conn.movenext to move around and this stuff is greek so how do you specify the field, move next, move previous with this style?

Bryan Schulz


#22578 From: "Timothy Rupp" <tim.rupp@...>
Date: Wed Nov 11, 2009 4:30 am
Subject: RE: ole db code
timrupp804
Offline Offline
Send Email Send Email
 

The DataReader is a different animal. It is a forward-only stream of data rows from a data source.

 

You need to call the ExecuteReader method of the OleDbCommand object.

 

From MSDN:

 

Public Sub ReadMyData(myConnString As String)

    Dim mySelectQuery As String = "SELECT OrderID, CustomerID FROM Orders"

    Dim myConnection As New OleDbConnection(myConnString)

    Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)

    myConnection.Open()

    Dim myReader As OleDbDataReader

    myReader = myCommand.ExecuteReader()

    ' Always call Read before accessing data.

    While myReader.Read()

        Console.WriteLine(myReader.GetInt32(0).ToString() + ", " _

           + myReader.GetString(1))

    End While

    ' always call Close when done reading.

    myReader.Close()

    ' Close the connection when done with it.

    myConnection.Close()

End Sub

 

 

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Bryan Schulz
Sent: Tuesday, November 10, 2009 10:33 PM
To: helpwithvb@yahoogroups.com
Subject: [helpwithvb] ole db code

 

 

hi,

 

i am experimenting with adding and retrieving data from an access 4.0 database with ole strings.

 

Imports System.Data.OleDb

Dim cn As OleDbConnection

Dim cmd As OleDbCommand

Dim dr As OleDbDataReader

 

i think i read you can use;

dr.NextResult()

to move to the next record

 

i am used to ado and using the conn.fields("employee name"), conn.movenext to move around and this stuff is greek so how do you specify the field, move next, move previous with this style?

 

Bryan Schulz


#22577 From: "Kishore" <gemini_kesa@...>
Date: Wed Nov 11, 2009 3:42 am
Subject: RE: Developing drivers in vb6
gemini_kesa
Offline Offline
Send Email Send Email
 
Yes i want to know just how we can develop drivers
Sent from my Nokia phone
-----Original Message-----
From: Tim Lewis
Sent:  11/11/2009 9:08:04 am
Subject:  RE: [helpwithvb] Developing drivers in vb6

The Nokia PC Suite already does that well, and is free.  Is this just for the
learning experience?



From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf
Of Kishore
Sent: Tuesday, November 10, 2009 10:26 PM
To: helpwithvb@yahoogroups.com
Subject: [helpwithvb] Developing drivers in vb6





Although there are drivers and software for nokia phone to connect to a pc. I
want to develop a driver software for my nokia phone such that a pc can identify
the phone and transfer data and retrieve data from the cell phone. Is it
possible by vb6

Sent from my Nokia phone

#22576 From: "Tim Lewis" <twlewis@...>
Date: Wed Nov 11, 2009 3:38 am
Subject: RE: Developing drivers in vb6
twlewis64
Offline Offline
Send Email Send Email
 

The Nokia PC Suite already does that well, and is free.  Is this just for the learning experience?

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Kishore
Sent: Tuesday, November 10, 2009 10:26 PM
To: helpwithvb@yahoogroups.com
Subject: [helpwithvb] Developing drivers in vb6

 

 

Although there are drivers and software for nokia phone to connect to a pc. I want to develop a driver software for my nokia phone such that a pc can identify the phone and transfer data and retrieve data from the cell phone. Is it possible by vb6

Sent from my Nokia phone


#22575 From: "Bryan Schulz" <b.schulz@...>
Date: Wed Nov 11, 2009 3:33 am
Subject: ole db code
bryan4772002
Offline Offline
Send Email Send Email
 
hi,
 
i am experimenting with adding and retrieving data from an access 4.0 database with ole strings.
 

Imports System.Data.OleDb

Dim cn As OleDbConnection

Dim cmd As OleDbCommand

Dim dr As OleDbDataReader

 

i think i read you can use;

dr.NextResult()

to move to the next record
 
i am used to ado and using the conn.fields("employee name"), conn.movenext to move around and this stuff is greek so how do you specify the field, move next, move previous with this style?
 
Bryan Schulz

#22574 From: "Kishore" <gemini_kesa@...>
Date: Wed Nov 11, 2009 3:25 am
Subject: Developing drivers in vb6
gemini_kesa
Offline Offline
Send Email Send Email
 
Although there are drivers and software for nokia phone to connect to a pc. I
want to develop a driver software for my nokia phone such that a pc can identify
the phone and transfer data and retrieve data from the cell phone. Is it
possible by vb6

Sent from my Nokia phone

#22573 From: "Timothy Rupp" <tim.rupp@...>
Date: Tue Nov 10, 2009 11:09 am
Subject: RE: Recordset in vb6
timrupp804
Offline Offline
Send Email Send Email
 

Thanks!

 

From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On Behalf Of Adelle Hartley
Sent: Tuesday, November 10, 2009 5:41 AM
To: helpwithvb@yahoogroups.com
Subject: Re: [helpwithvb] Recordset in vb6

 

 

Timothy Rupp wrote:
> I don't ever recall hearing this. During cleanup I always used to set ADO
> recordsets = Nothing. Perhaps Adelle has a perspective on this well in
> hand...listening Adelle?

Provided the recordset is declared locally and there are no other
variables outside that scope (i.e. global variables or byref arguments
to that routine) that refer to the recordset, it *will* go away by
itself whether you set it to nothing or not.

Furthermore, if there *are* global references to that recordset, setting
your local reference to nothing at the end of the routine will have no
effect.

As for harm, the only downside of redundantly setting something to
nothing are a couple of extra cpu instructions.

It is more important to ".Close" things that have a "Close" method.

The existence of a "Close" method on an object is a signal that the
developers weren't sure they could guarantee complete cleanup when the
last reference is cleared (whether done manually or not).

A common reason is a cyclic reference between objects, where "Close"
clears the object's internal references that would otherwise prevent it
from disappearing.

I recall this as being a particular issue with DAO objects, and I
suspect there are corners of ADO where this crops up, but I am unaware
of them by not using them.

Adelle.

___


#22572 From: Adelle Hartley <adelle@...>
Date: Tue Nov 10, 2009 10:41 am
Subject: Re: Recordset in vb6
adellehartley
Offline Offline
Send Email Send Email
 
Timothy Rupp wrote:
> I don't ever recall hearing this. During cleanup I always used to set ADO
> recordsets = Nothing. Perhaps Adelle has a perspective on this well in
> hand...listening Adelle?

Provided the recordset is declared locally and there are no other
variables outside that scope (i.e. global variables or byref arguments
to that routine) that refer to the recordset, it *will* go away by
itself whether you set it to nothing or not.

Furthermore, if there *are* global references to that recordset, setting
your local reference to nothing at the end of the routine will have no
effect.

As for harm, the only downside of redundantly setting something to
nothing are a couple of extra cpu instructions.

It is more important to ".Close" things that have a "Close" method.

The existence of a "Close" method on an object is a signal that the
developers weren't sure they could guarantee complete cleanup when the
last reference is cleared (whether done manually or not).

A common reason is a cyclic reference between objects, where "Close"
clears the object's internal references that would otherwise prevent it
from disappearing.

I recall this as being a particular issue with DAO objects, and I
suspect there are corners of ADO where this crops up, but I am unaware
of them by not using them.

Adelle.

#22571 From: Kenneth Danner <kwd@...>
Date: Tue Nov 10, 2009 10:33 am
Subject: RE: Recordset in vb6
racermand289
Offline Offline
Send Email Send Email
 
Way back when, I was taught that if you did not set it to nothing it was
still hanging around thus causing a memory leak.
I do not know if this is the case, I have never tested it.

All you automation guru's out there set us straight!


At 05:21 AM 11/10/2009, you wrote:

>I had closed the recordset as rs.close but is it necessary to set rs to
>nothing  because i never did that and didnt face a problem for that
>
>Sent from my Nokia phone
>-----Original Message-----
>From: Kenneth Danner
>Sent:  10/11/2009 3:43:24 pm
>Subject:  RE: [helpwithvb] Recordset in vb6
>
>
>I would like to know this also.... I to always close up and set to nothing....
>I've not seen any problem, but who's to say there were not any that I have
>not seen.
>
>
>TimeToExit:
>
>      '------------ Close the Connection --------------
>      rs.Close
>      cn.Close
>
>      Set rs = Nothing
>      Set cn = Nothing
>
>      Close
>      Err.Clear
>      Screen.MousePointer = 0
>      Exit Sub
>
>
>At 08:26 PM 11/9/2009, you wrote:
>
> >I don't ever recall hearing this. During cleanup I always used to set ADO
> >recordsets = Nothing. Perhaps Adelle has a perspective on this well in
> >hand...listening Adelle?
> >
> >/tr
> >
> >-----Original Message-----
> >From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On
> >Behalf Of Neiger, Bruce D
> >Sent: Monday, November 09, 2009 3:26 PM
> >To: helpwithvb@yahoogroups.com
> >Subject: RE: [helpwithvb] Recordset in vb6
> >
> >I recall this as well... but, for the life of me, I cannot recall why it can
> >be potentially harmful to set the rs to Nothing explicitly...
> >If the variable is the only reference, the object gets destroyed, but the
> >variable stays in scope.
> >If the variable is NOT the only reference, the object sticks around... but
> >only until the end of routine, when the variables go away and any remaining
> >references become meaningless or also go away.
> >
> >I guess I am curious as to the possible harm.
> >
> >-BDN
> >
> >________________________________
> >
> >From: helpwithvb@yahoogroups.com on behalf of Steve Manser
> >Sent: Sun 11/8/2009 10:58 AM
> >To: helpwithvb@yahoogroups.com
> >Subject: RE: [helpwithvb] Recordset in vb6
> >
> >
> >...
> >
> >In fact, I seem to also recall that we can really mess-up the well brewed
> >stew if we try
> >'to be good programmers', and write code to set the Recordsets to Nothing at
> >the end of the
> >sub-routine, because at the end of the sub-routine the ADO RS will go out of
> >scope, and will die naturally.
> >
> >We don't have to do anything, even if we think otherwise, or have a desire
> >to do more than we should.
> >
> >
> >
> >
> >
> >
> >
> >
> >------------------------------------
> >
> >Yahoo! Groups Links
> >
> >
> >
>
>
>
>------------------------------------
>
>Yahoo! Groups Links
>
>
>

#22570 From: "Kishore" <gemini_kesa@...>
Date: Tue Nov 10, 2009 10:21 am
Subject: RE: Recordset in vb6
gemini_kesa
Offline Offline
Send Email Send Email
 
I had closed the recordset as rs.close but is it necessary to set rs to nothing 
because i never did that and didnt face a problem for that

Sent from my Nokia phone
-----Original Message-----
From: Kenneth Danner
Sent:  10/11/2009 3:43:24 pm
Subject:  RE: [helpwithvb] Recordset in vb6


I would like to know this also.... I to always close up and set to nothing....
I've not seen any problem, but who's to say there were not any that I have
not seen.


TimeToExit:

      '------------ Close the Connection --------------
      rs.Close
      cn.Close

      Set rs = Nothing
      Set cn = Nothing

      Close
      Err.Clear
      Screen.MousePointer = 0
      Exit Sub


At 08:26 PM 11/9/2009, you wrote:

>I don't ever recall hearing this. During cleanup I always used to set ADO
>recordsets = Nothing. Perhaps Adelle has a perspective on this well in
>hand...listening Adelle?
>
>/tr
>
>-----Original Message-----
>From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On
>Behalf Of Neiger, Bruce D
>Sent: Monday, November 09, 2009 3:26 PM
>To: helpwithvb@yahoogroups.com
>Subject: RE: [helpwithvb] Recordset in vb6
>
>I recall this as well... but, for the life of me, I cannot recall why it can
>be potentially harmful to set the rs to Nothing explicitly...
>If the variable is the only reference, the object gets destroyed, but the
>variable stays in scope.
>If the variable is NOT the only reference, the object sticks around... but
>only until the end of routine, when the variables go away and any remaining
>references become meaningless or also go away.
>
>I guess I am curious as to the possible harm.
>
>-BDN
>
>________________________________
>
>From: helpwithvb@yahoogroups.com on behalf of Steve Manser
>Sent: Sun 11/8/2009 10:58 AM
>To: helpwithvb@yahoogroups.com
>Subject: RE: [helpwithvb] Recordset in vb6
>
>
>...
>
>In fact, I seem to also recall that we can really mess-up the well brewed
>stew if we try
>'to be good programmers', and write code to set the Recordsets to Nothing at
>the end of the
>sub-routine, because at the end of the sub-routine the ADO RS will go out of
>scope, and will die naturally.
>
>We don't have to do anything, even if we think otherwise, or have a desire
>to do more than we should.
>
>
>
>
>
>
>
>
>------------------------------------
>
>Yahoo! Groups Links
>
>
>

#22569 From: Kenneth Danner <kwd@...>
Date: Tue Nov 10, 2009 10:13 am
Subject: RE: Recordset in vb6
racermand289
Offline Offline
Send Email Send Email
 
I would like to know this also.... I to always close up and set to nothing....
I've not seen any problem, but who's to say there were not any that I have
not seen.


TimeToExit:

      '------------ Close the Connection --------------
      rs.Close
      cn.Close

      Set rs = Nothing
      Set cn = Nothing

      Close
      Err.Clear
      Screen.MousePointer = 0
      Exit Sub


At 08:26 PM 11/9/2009, you wrote:

>I don't ever recall hearing this. During cleanup I always used to set ADO
>recordsets = Nothing. Perhaps Adelle has a perspective on this well in
>hand...listening Adelle?
>
>/tr
>
>-----Original Message-----
>From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On
>Behalf Of Neiger, Bruce D
>Sent: Monday, November 09, 2009 3:26 PM
>To: helpwithvb@yahoogroups.com
>Subject: RE: [helpwithvb] Recordset in vb6
>
>I recall this as well... but, for the life of me, I cannot recall why it can
>be potentially harmful to set the rs to Nothing explicitly...
>If the variable is the only reference, the object gets destroyed, but the
>variable stays in scope.
>If the variable is NOT the only reference, the object sticks around... but
>only until the end of routine, when the variables go away and any remaining
>references become meaningless or also go away.
>
>I guess I am curious as to the possible harm.
>
>-BDN
>
>________________________________
>
>From: helpwithvb@yahoogroups.com on behalf of Steve Manser
>Sent: Sun 11/8/2009 10:58 AM
>To: helpwithvb@yahoogroups.com
>Subject: RE: [helpwithvb] Recordset in vb6
>
>
>...
>
>In fact, I seem to also recall that we can really mess-up the well brewed
>stew if we try
>'to be good programmers', and write code to set the Recordsets to Nothing at
>the end of the
>sub-routine, because at the end of the sub-routine the ADO RS will go out of
>scope, and will die naturally.
>
>We don't have to do anything, even if we think otherwise, or have a desire
>to do more than we should.
>
>
>
>
>
>
>
>
>------------------------------------
>
>Yahoo! Groups Links
>
>
>

#22568 From: "Timothy Rupp" <tim.rupp@...>
Date: Tue Nov 10, 2009 1:26 am
Subject: RE: Recordset in vb6
timrupp804
Offline Offline
Send Email Send Email
 
I don't ever recall hearing this. During cleanup I always used to set ADO
recordsets = Nothing. Perhaps Adelle has a perspective on this well in
hand...listening Adelle?

/tr

-----Original Message-----
From: helpwithvb@yahoogroups.com [mailto:helpwithvb@yahoogroups.com] On
Behalf Of Neiger, Bruce D
Sent: Monday, November 09, 2009 3:26 PM
To: helpwithvb@yahoogroups.com
Subject: RE: [helpwithvb] Recordset in vb6

I recall this as well... but, for the life of me, I cannot recall why it can
be potentially harmful to set the rs to Nothing explicitly...
If the variable is the only reference, the object gets destroyed, but the
variable stays in scope.
If the variable is NOT the only reference, the object sticks around... but
only until the end of routine, when the variables go away and any remaining
references become meaningless or also go away.

I guess I am curious as to the possible harm.

-BDN

________________________________

From: helpwithvb@yahoogroups.com on behalf of Steve Manser
Sent: Sun 11/8/2009 10:58 AM
To: helpwithvb@yahoogroups.com
Subject: RE: [helpwithvb] Recordset in vb6


...

In fact, I seem to also recall that we can really mess-up the well brewed
stew if we try
'to be good programmers', and write code to set the Recordsets to Nothing at
the end of the
sub-routine, because at the end of the sub-routine the ADO RS will go out of
scope, and will die naturally.

We don't have to do anything, even if we think otherwise, or have a desire
to do more than we should.

#22567 From: "Neiger, Bruce D" <Bruce.D.Neiger@...>
Date: Mon Nov 9, 2009 8:26 pm
Subject: RE: Recordset in vb6
thezorch
Offline Offline
Send Email Send Email
 
I recall this as well... but, for the life of me, I cannot recall why it can be
potentially harmful to set the rs to Nothing explicitly...
If the variable is the only reference, the object gets destroyed, but the
variable stays in scope.
If the variable is NOT the only reference, the object sticks around... but only
until the end of routine, when the variables go away and any remaining
references become meaningless or also go away.

I guess I am curious as to the possible harm.

-BDN

________________________________

From: helpwithvb@yahoogroups.com on behalf of Steve Manser
Sent: Sun 11/8/2009 10:58 AM
To: helpwithvb@yahoogroups.com
Subject: RE: [helpwithvb] Recordset in vb6


...

In fact, I seem to also recall that we can really mess-up the well brewed stew
if we try
'to be good programmers', and write code to set the Recordsets to Nothing at the
end of the
sub-routine, because at the end of the sub-routine the ADO RS will go out of
scope, and will die naturally.

We don't have to do anything, even if we think otherwise, or have a desire to do
more than we should.

#22566 From: Steve Trigero <seecwriter@...>
Date: Mon Nov 9, 2009 3:57 am
Subject: Re: Re: Excel
seecwriter
Offline Offline
Send Email Send Email
 
> However, since your Excel Objects are created
>and used within any number of sub-routines
> why can't you include Tim's code example
>in every routine that creates an
> Excel Object Instance ?

Are you referring to the code that sets
all excel objects to Nothing, since that's
the only code I've seen from Tim? Wouldn't
that kill excel before it was ever opened?

Sub Myfunc()

Dim oXL as Excel.Application

Set oXL = CreateObject("Excel.Application")

'Fill spreadsheet with data.

oXL.Visible = True

oXL.Close()        '<--- Haven't I just defeated everything I did before?
Set oXL = Nothing

End Sub



From: Steve Manser <smanser@...>
To: helpwithvb@yahoogroups.com
Sent: Sun, November 8, 2009 9:23:55 AM
Subject: RE: [helpwithvb] Re: Excel

 

The Form's Terminate Event fires last, and
I was told that is where we should perform
the clean-up of our Objects.

However, since your Excel Objects are created
and used within any number of sub-routines
why can't you include Tim's code example
in every routine that creates an
Excel Object Instance ?

When we get down to the Unload Event Handler
we will not have a reference to any of those
Excel Objects that were created within the
earlier sub-routines.

Unless I have forgotten all about the easy
way to determine and obtain those references
for those Excel creations so we can do the
clean-up when our program closes.

I lean towards using Tim's code in each routine.

Any teachers out there on duty today ? :)

Many Thanks,
Steve

____________ _________ _________ __

From: helpwithvb@yahoogro ups.com
On Behalf Of Timothy Rupp
Sent: Saturday, November 07, 2009 11:20 PM
To: helpwithvb@yahoogro ups.com
Subject: RE: [helpwithvb] Re: Excel

…And VB6 doesn’t allow you to call
a cleanup subroutine from the unload event ?

/tr

From: helpwithvb@yahoogro ups.com
On Behalf Of seecwriter
Sent: Saturday, November 07, 2009 11:03 PM
To: helpwithvb@yahoogro ups.com
Subject: [helpwithvb] Re: Excel

Because only in the unload event does my
application have any inkling that the user is done.

.
.
--- In helpwithvb@yahoogro ups.com

"Timothy Rupp" <tim.rupp@.. .> wrote:
>
> Tell me again why must it take place in the unload event?
>
> /tr
>
> From: helpwithvb@yahoogro ups.com
> On Behalf Of Steve Trigero
> Sent: Saturday, November 07, 2009 1:52 PM
> To: helpwithvb@yahoogro ups.com
> Subject: Re: [helpwithvb] Re: Excel
>
> Then what you're saying is that all excel objects/variables
> have to be globally public in scope. That is the only way
> I will be able to set them to Nothing in an Unload event.
>
> _____
>
> From: Timothy Rupp <tim.rupp@.. .>
> To: helpwithvb@yahoogro ups.com
> Sent: Sat, November 7, 2009 4:20:23 AM
> Subject: RE: [helpwithvb] Re: Excel
>
> No…as is evident from your experience.
>
> All variables are objects; however, all objects are not variables.
>
> It's fairly easy to manage a variable or reference
to a variable and when it goes out of scope you
delete the reference. However, your Excel object
is an entire process that has its own set of variables
and objects. It will hang around until you specifically
tell it to go away. It is very common to quit the Excel
object and discover that the program is still an active process.

You need to go all the way and drive the stake
through the heart and set the object to Nothing
before it actually goes away.
>
> From: helpwithvb@yahoogro ups.com
> On Behalf Of seecwriter
> Sent: Friday, November 06, 2009 7:37 PM
> To: helpwithvb@yahoogro ups.com
> Subject: [helpwithvb] Re: Excel
>
> Good guess. I'll be moving on to the VB.Net version
> later. In the mean time, all my excel objects are
> local variables of a function. Don't they get destroyed
> when the function returns, like all local variables?
>
> --- In helpwithvb@yahoogro ups.com,
>
> "Timothy Rupp" <tim.rupp@> wrote:
> >
> > Guessing that this is using VB6.
> >
> > Make sure that your are closing all your objects and
> > destroying the instances in your program.
> >
> > Something similar to this:
> >
> > Set oRng = Nothing
> > Set oSht = Nothing
> > oWbk.Close SaveChanges: =False
> >
> > Set oWbk = Nothing
> > oExcel.Quit
> > Set oExcel = Nothing
> >
> >
> >
> > From: helpwithvb@yahoogro ups.com
> > On Behalf Of seecwriter
> > Sent: Friday, November 06, 2009 6:34 PM
> > To: helpwithvb@yahoogro ups.com
> > Subject: [helpwithvb] Excel
> >
> > As I've been working on this Excel project, I run my app, which opens an
> > Excel spreadsheet and populates it. And It appears to be working pretty
> > well. So I close my app, close Excel, do some more editing, then retest.
> > You know the iterative process.
> >
> > So I notice that the excel book name is something like "Book 9" on one of my
> > tests. That looks weird. So I close my project and Excel, and I bring up the
> > task manager. It shows about 9 copies of Excel running. What gives? Why
> > doesn't excel close down when I click the little red "X"?
> >
>


#22565 From: "Kishore" <gemini_kesa@...>
Date: Sun Nov 8, 2009 5:50 pm
Subject: Working with webbrowser control in vb6
gemini_kesa
Offline Offline
Send Email Send Email
 
I am using webbrowser control and sent text to a textbox in a webpage by using
getElementById  but i want to get the data from a html table and store it to my
database.but tables wont have any name or id to identify then how can i get a
table and then its rows.

Sent from my Nokia phone

Messages 22565 - 22594 of 22756   Newest  |  < Newer  |  Older >  |  Oldest
Advanced
Add to My Yahoo!      XML What's This?

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help