Wrox Programmer Forums
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 20th, 2007, 09:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

did you set the index property of text1 to 0????
try something like this:

Code:
set txtobj = load text1.index(objectcount)
and your code... instead of controls.add

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old June 20th, 2007, 11:12 PM
Authorized User
 
Join Date: Sep 2003
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to prabodh_mishra
Default

dim withevents txtObj as textbox

controls.add .......
.
.
.
.

it will allow you to pick events for this dynamic control
Private Sub txtObj_Click()

End Sub

Cheers,
Prabodh
 
Old June 27th, 2007, 07:34 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

Private Sub Form_Load()
    Dim i As Integer

    For i = 1 To 10
        Load Me.txt(i)

        Me.txt(i).Top = i * 500
        Me.txt(i).Visible = True
    Next i
End Sub


 
Old June 29th, 2007, 01:52 AM
Authorized User
 
Join Date: Jun 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Couldn't make i work?

Dim WithEvents txtObj As TextBox

Private Sub Form_Load()
Set txtObj = Controls.Add("VB.TextBox", "txt")
With txtObj
    .Visible = True
    .Text = "TEST"
    .Top = 120
    .Left = 120
    .Width = 5000
    .Height = 300
End With
End Sub

Private Sub txt_Click()
MsgBox "ok"
End Sub

THANKS!

 
Old June 29th, 2007, 02:46 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

u dont hv to declare Dim WithEvents txtObj As TextBox

just place a TextBox (name = txt) on the form and set Index property = 0 in design time
then just use this code


 
Old June 29th, 2007, 03:08 AM
Authorized User
 
Join Date: Jun 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Still can't make it work, heres the complete text for the form:

VERSION 5.00
Begin VB.Form Form1
   Caption = "Form1"
   ClientHeight = 3195
   ClientLeft = 60
   ClientTop = 345
   ClientWidth = 4680
   LinkTopic = "Form1"
   ScaleHeight = 3195
   ScaleWidth = 4680
   StartUpPosition = 3 'Windows Default
   Begin VB.TextBox txt
      Height = 495
      Index = 0
      Left = 1800
      TabIndex = 0
      Text = "Text1"
      Top = 1320
      Width = 1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim WithEvents txtObj As TextBox

Private Sub Form_Load()
Set txtObj = Controls.Add("VB.TextBox", "txt")
With txtObj
' .Index = 1
    .Visible = True
    .Text = "TEST"
    .Top = 120
    .Left = 120
    .Width = 5000
    .Height = 300
End With
End Sub

Private Sub txt_Change(Index As Integer)
MsgBox "ok"
End Sub


THANKS

 
Old June 29th, 2007, 03:31 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

gimme ur mail is...i will send u a sample application...

 
Old June 29th, 2007, 03:33 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

gimme ur mail id...i will send u a sample code

 
Old June 29th, 2007, 07:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there... already told you this.. replace
Code:
Set txtObj = Controls.Add("VB.TextBox", "txt")
with this:
Code:
set txtobj = load txt.index(objectcount)
where objectcount is the next index you want...



HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old August 8th, 2007, 03:43 AM
Authorized User
 
Join Date: Sep 2003
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to prabodh_mishra
Default

Sorry Off late I was little busy and couldn't saw it.
You are making a mistake that is why it is not working even after WithEvents.

Private Sub txt_Click()
MsgBox "ok"
End Sub

Instead it should be
Private Sub txtObj_Click()


Cheers,
Prabodh





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot update control from DLL events sreecareer ASP.NET 2.0 Basics 0 October 27th, 2008 08:01 PM
Need Help with Dynamic Link Label Click Events chobo2 C# 4 November 8th, 2007 03:47 AM
Events for custom control in datarepeater?? lauriedthompson VB How-To 0 June 20th, 2007 05:11 AM
Control that detects events Eyob_the_pro C# 7 February 14th, 2007 11:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.