Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 12-12-2003, 11:40 AM   #1
InsaneGreen
Confirmed User
 
Join Date: Aug 2003
Location: southern california
Posts: 996
a little VB help...

im trying to decide which control to use by using a string for a mailer.. each target has 4 email bodys it rotates thru, named like this
asianbody1.text
asianbody2.text
asianbody3.text
asianbody4.text

heres what im having trouble with:
Dim thebody As Control
target$="asian"
bodycount$="1"
thebody = (target$ & "body" & bodycount$)
MsgBox (thebody.Text)


here is the error im getting

does anyone know how to make something like this work? thanks in advance!!!
InsaneGreen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-12-2003, 11:41 AM   #2
fletcher
Confirmed User
 
Join Date: Jan 2003
Location: Austin, TX
Posts: 698
I'm not even that good at VB, but it looks like you're setting "thebody" to a string then referencing it like an object.
__________________
 
[email protected]
ICQ: 6411138
fletcher is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-12-2003, 11:42 AM   #3
fletcher
Confirmed User
 
Join Date: Jan 2003
Location: Austin, TX
Posts: 698
Quote:
Originally posted by fletcher
I'm not even that good at VB, but it looks like you're setting "thebody" to a string then referencing it like an object.
Ohhh...I see what you're trying to do. Dynamically build the variable.
__________________
 
[email protected]
ICQ: 6411138
fletcher is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-12-2003, 11:43 AM   #4
InsaneGreen
Confirmed User
 
Join Date: Aug 2003
Location: southern california
Posts: 996
Quote:
Originally posted by fletcher


Ohhh...I see what you're trying to do. Dynamically build the variable.
exactly, any ideas?
InsaneGreen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-12-2003, 01:22 PM   #5
Mr. T
Registered User
 
Join Date: Jun 2002
Posts: 62

Hey, what's up...here's a sample for you.
I'd open a new project and paste this in there. Then make your modifications where ever. You'll notice when the form loads up, it populates the Bodies Collection. From there it just calls one out at random. You can see the output by making a cheap test, In my case it's "MsgBox GetRandBody" GetRandBody() returns as a hahahahahahahaha

Hope this helps...any other questions?
-Brad

Option Explicit
'Body Randomizer - by SuperBrad
'This may seem like a morbid example, but it works...
Public Bodies As New Collection 'Public Body Collection...
'Returns your random body as a string for usage anywhere.
Public Function GetRandBody() As String
GetRandBody = CStr(Bodies(Random(1, Bodies.Count)))
End Function
'Loads your body string into the Bodies Collection
Public Function LoadBodies(strBody As String)
Bodies.Add strBody
End Function
'This Function Generates Your Random Number (The High is the body count)
Public Function Random(lngLow As Long, lngHigh As Long) As Long
Rnd -1
Randomize
Random = Int((lngHigh - lngLow + 1) * Rnd(Rnd)) + lngLow
End Function
Private Sub Command1_Click()

End Sub

Private Sub Form_Load()
Set Bodies = New Collection
LoadBodies "This is a body1"
LoadBodies "This is a body2"
LoadBodies "This is a body3"
LoadBodies "This is a body4"
MsgBox GetRandBody
End Sub
__________________
Mr. T!
Mr. T is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-12-2003, 01:25 PM   #6
Mr. T
Registered User
 
Join Date: Jun 2002
Posts: 62
...almost forgot.

You can iterate through that bodies collection if you did this.

Dim i as Long

For i = 1 to Bodies.Count
Msgbox Bodies(i)
Next i
__________________
Mr. T!
Mr. T is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-12-2003, 02:27 PM   #7
Mr. T
Registered User
 
Join Date: Jun 2002
Posts: 62
Yea...not a really busy day at work today; so I'll explain why I did what I did.

1. I'm awesome...

No, but the thing to keep in mind is that storing large chunks of text in GUI "holders" in your case the textboxes is a bad way of managing resources. Every time you use another control, you are adding to the horrible GUI Beast's overhead. Even if the text boxes were off-screen, they still take up resources. And the more stuff you have painting on your forms the slower your app is going to be; especially if they're filled with lots of text/html!

So by using Collections, you now have a means to order and structure your data. And it's easy as sin to add/remove/count your resources!

If you didn't know already, the extensions of the Collection type are as follows:

Collection.Add - Adds to your collection
Collection.Remove(index) - removes the "nth" item from your collection (remember they're ordered 1-n, unlike normall arrays {0-n})
Collection.Count - returns the number of elements in your collection.
And finally Collection.Item(index) - returns the "nth" item in your collection.

So now that you've got this slick object to play with - I would suggest (since you're mailing) to use another collection (let's say Subjects) to manage all of your subjects so that you could randomize those as well!

Hope this little tutorial was worthwhile...I'd be happy to answer more questions while I'm bored.

Until next time,
Brad
__________________
Mr. T!
Mr. T is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.