|
-
Feb 27th, 2009, 03:06 PM
#1
Thread Starter
Addicted Member
[RESOLVED] place text into textbox array from menu
Hi, I have a textbox array called lanastart, I also have a right click menu that brings up times from 9:00am to 10:00pm. My question is how do I get that time into the textbox that I right clicked on and selected the time from. I think my biggest problem is that the text box is in an array 0 to 27.
this is the code for the right click menu (Thanks to MartinLiss)
Code:
Private Sub lanastart_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
lanastart(Index).Enabled = False
lanastart(Index).Enabled = True
PopupMenu timemenu
lanastart(Index).Text = timemnu
End If
End Sub
Thank you
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN
-
Feb 27th, 2009, 03:09 PM
#2
Re: place text into textbox array from menu
Why dont you use a combobox for this purpose? Thats seems like ideal, and easy to do.
-
Feb 27th, 2009, 04:06 PM
#3
Re: place text into textbox array from menu
If I understand you correctly....
Code:
Private Sub lanastart_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
lanastart(Index).Enabled = False
lanastart(Index).Enabled = True
timemenu.Tag = Index
PopupMenu timemenu
timemenu.Tag = ""
End If
End Sub
' then in your submenus click events (the submenus on timemenu)
' I have no idea what your submenu names are, so I will guess mnuHours
Private Sub mnuHours_Click(Index As Integer)
If timemenu.Tag <> "" Then
lanastart(Val(timemenu.Tag)).Text = mnuHours(Index).Caption
End If
End Sub
-
Feb 27th, 2009, 05:13 PM
#4
Thread Starter
Addicted Member
Re: place text into textbox array from menu
Thanks for the thought Jim Davis, I had originaly started this project with comboboxes but soon decided the textboxes looked better, I have over 352 textboxes on one page in 12 different arrays.
Thank you LaVolpe, this works well. Is there a way I can alter it to include another array without adding another menu?
like
from this
Code:
If timemenu.Tag <> "" Then
lanastart(Val(timemenu.Tag)).Text = tenCaption
End If
to this
Code:
If timemenu.Tag <> "" Then
**the place that was right clicked**(Val(timemenu.Tag)).Text = ten.Caption
End If
Thank you for your time,
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN
-
Feb 27th, 2009, 05:21 PM
#5
Re: place text into textbox array from menu
Think I get it. You have other textbox arrays besides lanastart? Then maybe...
Code:
Private Sub lanastart_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
lanastart(Index).Enabled = False
lanastart(Index).Enabled = True
timemenu.Tag = "lanastart" & vbTab & Index ' << changed
PopupMenu timemenu
timemenu.Tag = ""
End If
End Sub
' then to apply the caption, using the same menus
If timemenu.Tag <> "" Then
Dim tabPos As Integer, ctrlName As String, ctrlIndex As Integer
tabPos = InStr(timemenu.Tag, vbTab)
If tabPos Then
ctrlName = Left$(timemenu.Tag, tabPos-1)
ctrlIndex = Mid$(timemenu.Tag, tabPos+1)
Me.Controls(ctrlName)(ctrlIndex).Text = tenCaption
End If
End If
Edited: After some thought, this is a bit simpler and less code overall
Code:
' in your declarations section add this
Dim TextBoxForMenus As VB.TextBox
Private Sub lanastart_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
lanastart(Index).Enabled = False
lanastart(Index).Enabled = True
Set TextBoxForMenus = lanastart(Index)
PopupMenu timemenu
Set TextBoxForMenus = Nothing
End If
End Sub
' then to apply the caption, using the same menus
If Not TextBoxForMenus Is Nothing Then TextBoxForMenus.Text = tenCaption
Last edited by LaVolpe; Feb 27th, 2009 at 07:34 PM.
-
Feb 27th, 2009, 07:47 PM
#6
Thread Starter
Addicted Member
Re: place text into textbox array from menu
Thank you LaVolpe, that is exactly what I was trying to do.
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|