OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 25-03-2008, 14:57
bprice's Avatar
bprice bprice is offline
Member
 
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default Collections??

Forgive my ignorance, as VB is something I only mess around with occasionally...

If I do something like:

Dim Stuff as New Collection
Stuff.Add (Object1)
Stuff.Add (Object2)

For Each Thing in Stuff
Call Myfunction(Thing)
Next Thing

And Then a function that has:

Function MyFunction(ByRef ItemName As Object) As Object
ItemName.Text = "balh blah blah"
End Function

What am I doing wrong... I try something like this... and it gets to the "Call Myfunction(Thing) and says an object is required... I thought "thing" was an object (on each next it changes through the list of objects) because is added it to the stuff collection... object1, object 2 etc.

What am I doing wrong?

Thanks in Advance

B
Reply With Quote
  #2  
Old 25-03-2008, 15:51
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

probably Thing should be declared As Object too
Reply With Quote
  #3  
Old 25-03-2008, 17:25
bprice's Avatar
bprice bprice is offline
Member
 
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default nope...

i dim thing as object and still get "object required"

now whats odd is at work, i got that error any time i tried it, at home on my home computer... if i dim thing as object I get "object required", however... if I don't Dim thing as object and simply use the original example I first posted earlier today... i get the error "Compile Error: Can't find project or library"

I'm confused!
Reply With Quote
  #4  
Old 25-03-2008, 17:27
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

then post all the related code
Reply With Quote
  #5  
Old 26-03-2008, 05:45
bprice's Avatar
bprice bprice is offline
Member
 
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default Gms

Here is a GMS file with a form that shows what I am trying to do... there are probably a million different ways to do what I need... but with my very limited knowledge of VB... this is what I came up with....

Since I posted this... I messed around with a few things, and have noticed that "MyObject" doesn't cantain the object name like i want it to, but it's in fact containing the default text in each textbox...

so why is it it's looking at the text in the object and trying to send it to my function rather then the object name itself??? I need it to send the object names I added in the collection to my function....
Attached Files
File Type: gms testscripts.gms (17.5 KB, 255 views)

Last edited by bprice; 26-03-2008 at 05:53. Reason: found new info
Reply With Quote
  #6  
Old 26-03-2008, 07:19
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

ah, that's because the controls have a 'default' property which is fed upon ambiguous access (no explicit indication of object type). By explicit I mean: set ObjVar=TextBox1 :-)

anyway here's a trick I use for the task you need, I think it's pretty handy:
Code:
Private Sub EnableControls (ByVal bEnable As Boolean, ParamArray ctls())
   
   Dim var As Variant, bg&, fg&, txt$
   if bEnable then bg=vbWindowBackground: fg=vbWindowText: txt="" _
              else bg=vbGrayText: fg=vb3DDKShadow: txt="N/A"
   For Each var In ctls
      var.Enabled = bEnable
      var.BackColor = bg
      var.ForeColor = fg
      var.Text = txt
   Next
End Sub
This is how I call it:
Code:
EnableControls true, TextBox1, TextBox2, TextBox3
......
EnableControls false, TextBox1, TextBox2, TextBox3
P.S. of course there are a few other ways :-)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 18:35.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com