Selecting/moving Lines
Hey there, I am hoping someone can help me out? I have a picbox where someone can draw lines and circles. Allowing the person to draw is the simple part but... What I want to have happen is after a person is done drawing, I want allow them to be able to select a line/circle(ie. change the line/circle color) and then let them drag the line/circle to another location on the picbox? Any help would be greatly appreciated!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Moving Lines In A Text Lines
I am creating a replay for a game and I am keeping the info for it in a text file but after 5 seconds I want to clear out anything over 5 seconds old and continue to add. I can figure most of it out cept for the whole part about it removing the first line and moving the rest of the lines up. I am adding to the file every 1/2 second for 5 seconds. Heres what I have so far....
VB Code:
Open "C:Game
eplay.txt" For Append As #1TotTime = Int(Timer) Print #1, Int(Timer); "lblbox(" & Index & ")"If Int(Timer) - TotTime = 5 Then
lol, not much but I can't figure out how do move the lines. Would I just kinda have a second file and copy the lines into the new file and just clear out the old one and so on? But that doesn't seem like an appropriate way to go. Any help with this situation would be muchly appreciated. Thank you and good day.
Selecting Lines In Rtb
hey,
i was wonderin if anyone can tell me how this can be done,
the problem is that, i have a richtextbox and i want it to search for a word, i know how to do this, but wat i need to know is, when it finds the word how can i then make it highlight the line that it found the word on. and print this line into anythin else like a lable or a listbox.
hope some1 knows wat i mean
MsFlexGrid Selecting Non Contiguous Lines
Is there a way to select non consecutive lines in a FlexGrid as you would for files in the Windows Explorer by holding the CTRL key ? I've tried to look for a property that would allow this but couldn't find any.
Moving Lines
I have a canvas to the right of a window and a toolbox to the left. The user drags elements from the toolbox to the left and drops them on the canvas. Then he can move the elements drawn on the canvas around it by dragging them around the canvas area. He can also link two or more elements by right clicking and dragging in between the elements he wishes to link on the canvas.
Till here all's working well. I am now attempting to move the links associated with an element while the element is being dragged (with the left mouse button) on the canvas. For this, I use rubber banding (the XOR raster operation R2_NOT). A snapshot shows you how it works as of now and what is the problem I am facing. Can you advise me why the lines are not being erased properly.
Code:
Private Sub picCanvas_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim LngCounter As Long
If Button = vbLeftButton Then
If LngNumberOfANSIToolsOnBoard > 0 Then
For LngCounter = 0 To LngNumberOfANSIToolsOnBoard - 1
If PtInRect(ANSIToolsOnBoard(LngCounter).Dimensions, X, Y) Then
LSet PreviouslySelectedToolOnBoard = ANSIToolsOnBoard(LngCounter)
CurrentOffsetX = X - ANSIToolsOnBoard(LngCounter).Dimensions.Left
CurrentOffsetY = Y - ANSIToolsOnBoard(LngCounter).Dimensions.Top
SelectedElementType = ANSIElement
LngToolIndexInToolBox = ANSIToolsOnBoard(LngCounter).DrawingToolIndex
BoolIsElementBeingDraggedFromCanvas = True
LngSelectedANSIToolOnBoardArrayIndex = LngCounter
EraseTextRectangle
Exit Sub
End If
Next LngCounter
End If
If LngNumberOfOtherToolsOnBoard > 0 Then
For LngCounter = 0 To LngNumberOfOtherToolsOnBoard - 1
If PtInRect(OtherToolsOnBoard(LngCounter).Dimensions, X, Y) Then
LSet PreviouslySelectedToolOnBoard = OtherToolsOnBoard(LngCounter)
CurrentOffsetX = X - OtherToolsOnBoard(LngCounter).Dimensions.Left
CurrentOffsetY = Y - OtherToolsOnBoard(LngCounter).Dimensions.Top
SelectedElementType = OtherElement
LngToolIndexInToolBox = OtherToolsOnBoard(LngCounter).DrawingToolIndex
BoolIsElementBeingDraggedFromCanvas = True
LngSelectedOtherToolOnBoardArrayIndex = LngCounter
EraseTextRectangle
Exit Sub
End If
Next LngCounter
End If
ElseIf Button = vbRightButton Then
In the MouseMove I call a method called MoveLinks in order to move the links associated with the drawing element while the drawing element is being moved.
Code:
Dim LngCounter As Long
MDI.sbrWorkflowDesigner.Panels("sbrpnlMouseCo-ordinates").Text = X & ", " & Y
MDI.sbrWorkflowDesigner.Panels("sbrpnlToolTips").Text = vbNullString
If Button = vbLeftButton Then
If BoolIsElementBeingDraggedFromCanvas Then
Call MoveTool(X, Y)
If PreviouslySelectedToolOnBoard.IsLinked Then Call MoveLinks(X, Y)
End If
ElseIf Button = vbRightButton Then
'Blah.....blah...blah...
The MoveLinks method is code listed below:
Code:
Public Sub MoveLinks(ByVal X As Long, ByVal Y As Long)
If PreviouslySelectedToolOnBoard.IsLinked Then
If PreviouslySelectedToolOnBoard.NumberOfLinks > 0 Then
For LngCounter = 0 To UBound(PreviouslySelectedToolOnBoard.Links)
MoveToEx frmCanvas.picCanvas.hDC, PreviouslySelectedToolOnBoard.Links(LngCounter).ToPoint.X, _
PreviouslySelectedToolOnBoard.Links(LngCounter).ToPoint.Y, _
ByVal 0&
SetROP2 frmCanvas.picCanvas.hDC, R2_NOT
LineTo frmCanvas.picCanvas.hDC, PreviouslySelectedToolOnBoard.Links(LngCounter).FromPoint.X, _
PreviouslySelectedToolOnBoard.Links(LngCounter).FromPoint.Y
MoveToEx frmCanvas.picCanvas.hDC, PreviouslySelectedToolOnBoard.Links(LngCounter).ToPoint.X, _
PreviouslySelectedToolOnBoard.Links(LngCounter).ToPoint.Y, _
ByVal 0&
SetROP2 frmCanvas.picCanvas.hDC, R2_NOT
LineTo frmCanvas.picCanvas.hDC, X, Y
With PreviouslySelectedToolOnBoard.Links(LngCounter)
With .FromPoint
.X = X
.Y = Y
End With
End With
With PreviouslySelectedToolOnBoard.Links(LngCounter)
With .PreviousPassThroughPoint
.X = X
.Y = Y
End With
End With
Next LngCounter
End If
End If
End Sub
Moving Lines
I have a canvas to the right of a window and a toolbox to the left. The user drags elements from the toolbox to the left and drops them on the canvas. Then he can move the elements drawn on the canvas around it by dragging them around the canvas area. He can also link two or more elements by right clicking and dragging in between the elements he wishes to link on the canvas.
Till here all's working well. I am now attempting to move the links associated with an element while the element is being dragged (with the left mouse button) on the canvas. For this, I use rubber banding (the XOR raster operation R2_NOT). A snapshot shows you how it works as of now and what is the problem I am facing. Can you advise me why the lines are not being erased properly.
Code:
Private Sub picCanvas_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim LngCounter As Long
If Button = vbLeftButton Then
If LngNumberOfANSIToolsOnBoard > 0 Then
For LngCounter = 0 To LngNumberOfANSIToolsOnBoard - 1
If PtInRect(ANSIToolsOnBoard(LngCounter).Dimensions, X, Y) Then
LSet PreviouslySelectedToolOnBoard = ANSIToolsOnBoard(LngCounter)
CurrentOffsetX = X - ANSIToolsOnBoard(LngCounter).Dimensions.Left
CurrentOffsetY = Y - ANSIToolsOnBoard(LngCounter).Dimensions.Top
SelectedElementType = ANSIElement
LngToolIndexInToolBox = ANSIToolsOnBoard(LngCounter).DrawingToolIndex
BoolIsElementBeingDraggedFromCanvas = True
LngSelectedANSIToolOnBoardArrayIndex = LngCounter
EraseTextRectangle
Exit Sub
End If
Next LngCounter
End If
If LngNumberOfOtherToolsOnBoard > 0 Then
For LngCounter = 0 To LngNumberOfOtherToolsOnBoard - 1
If PtInRect(OtherToolsOnBoard(LngCounter).Dimensions, X, Y) Then
LSet PreviouslySelectedToolOnBoard = OtherToolsOnBoard(LngCounter)
CurrentOffsetX = X - OtherToolsOnBoard(LngCounter).Dimensions.Left
CurrentOffsetY = Y - OtherToolsOnBoard(LngCounter).Dimensions.Top
SelectedElementType = OtherElement
LngToolIndexInToolBox = OtherToolsOnBoard(LngCounter).DrawingToolIndex
BoolIsElementBeingDraggedFromCanvas = True
LngSelectedOtherToolOnBoardArrayIndex = LngCounter
EraseTextRectangle
Exit Sub
End If
Next LngCounter
End If
ElseIf Button = vbRightButton Then
In the MouseMove I call a method called MoveLinks in order to move the links associated with the drawing element while the drawing element is being moved.
Code:
Dim LngCounter As Long
MDI.sbrWorkflowDesigner.Panels("sbrpnlMouseCo-ordinates").Text = X & ", " & Y
MDI.sbrWorkflowDesigner.Panels("sbrpnlToolTips").Text = vbNullString
If Button = vbLeftButton Then
If BoolIsElementBeingDraggedFromCanvas Then
Call MoveTool(X, Y)
If PreviouslySelectedToolOnBoard.IsLinked Then Call MoveLinks(X, Y)
End If
ElseIf Button = vbRightButton Then
'Blah.....blah...blah...
The MoveLinks method is code listed below:
Code:
Public Sub MoveLinks(ByVal X As Long, ByVal Y As Long)
If PreviouslySelectedToolOnBoard.IsLinked Then
If PreviouslySelectedToolOnBoard.NumberOfLinks > 0 Then
For LngCounter = 0 To UBound(PreviouslySelectedToolOnBoard.Links)
MoveToEx frmCanvas.picCanvas.hDC, PreviouslySelectedToolOnBoard.Links(LngCounter).ToPoint.X, _
PreviouslySelectedToolOnBoard.Links(LngCounter).ToPoint.Y, _
ByVal 0&
SetROP2 frmCanvas.picCanvas.hDC, R2_NOT
LineTo frmCanvas.picCanvas.hDC, PreviouslySelectedToolOnBoard.Links(LngCounter).FromPoint.X, _
PreviouslySelectedToolOnBoard.Links(LngCounter).FromPoint.Y
MoveToEx frmCanvas.picCanvas.hDC, PreviouslySelectedToolOnBoard.Links(LngCounter).ToPoint.X, _
PreviouslySelectedToolOnBoard.Links(LngCounter).ToPoint.Y, _
ByVal 0&
SetROP2 frmCanvas.picCanvas.hDC, R2_NOT
LineTo frmCanvas.picCanvas.hDC, X, Y
With PreviouslySelectedToolOnBoard.Links(LngCounter)
With .FromPoint
.X = X
.Y = Y
End With
End With
With PreviouslySelectedToolOnBoard.Links(LngCounter)
With .PreviousPassThroughPoint
.X = X
.Y = Y
End With
End With
Next LngCounter
End If
End If
End Sub
Moving Lines
I have a canvas to the right of a window and a toolbox to the left. The user drags elements from the toolbox to the left and drops them on the canvas. Then he can move the elements drawn on the canvas around it by dragging them around the canvas area. He can also link two or more elements by right clicking and dragging in between the elements he wishes to link on the canvas.
Till here all's working well. I am now attempting to move the links associated with an element while the element is being dragged (with the left mouse button) on the canvas. For this, I use rubber banding (the XOR raster operation R2_NOT). A snapshot shows you how it works as of now and what is the problem I am facing. Can you advise me why the lines are not being erased properly.
Code:
Private Sub picCanvas_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim LngCounter As Long
If Button = vbLeftButton Then
If LngNumberOfANSIToolsOnBoard > 0 Then
For LngCounter = 0 To LngNumberOfANSIToolsOnBoard - 1
If PtInRect(ANSIToolsOnBoard(LngCounter).Dimensions, X, Y) Then
LSet PreviouslySelectedToolOnBoard = ANSIToolsOnBoard(LngCounter)
CurrentOffsetX = X - ANSIToolsOnBoard(LngCounter).Dimensions.Left
CurrentOffsetY = Y - ANSIToolsOnBoard(LngCounter).Dimensions.Top
SelectedElementType = ANSIElement
LngToolIndexInToolBox = ANSIToolsOnBoard(LngCounter).DrawingToolIndex
BoolIsElementBeingDraggedFromCanvas = True
LngSelectedANSIToolOnBoardArrayIndex = LngCounter
EraseTextRectangle
Exit Sub
End If
Next LngCounter
End If
If LngNumberOfOtherToolsOnBoard > 0 Then
For LngCounter = 0 To LngNumberOfOtherToolsOnBoard - 1
If PtInRect(OtherToolsOnBoard(LngCounter).Dimensions, X, Y) Then
LSet PreviouslySelectedToolOnBoard = OtherToolsOnBoard(LngCounter)
CurrentOffsetX = X - OtherToolsOnBoard(LngCounter).Dimensions.Left
CurrentOffsetY = Y - OtherToolsOnBoard(LngCounter).Dimensions.Top
SelectedElementType = OtherElement
LngToolIndexInToolBox = OtherToolsOnBoard(LngCounter).DrawingToolIndex
BoolIsElementBeingDraggedFromCanvas = True
LngSelectedOtherToolOnBoardArrayIndex = LngCounter
EraseTextRectangle
Exit Sub
End If
Next LngCounter
End If
ElseIf Button = vbRightButton Then
In the MouseMove I call a method called MoveLinks in order to move the links associated with the drawing element while the drawing element is being moved.
Code:
Dim LngCounter As Long
MDI.sbrWorkflowDesigner.Panels("sbrpnlMouseCo-ordinates").Text = X & ", " & Y
MDI.sbrWorkflowDesigner.Panels("sbrpnlToolTips").Text = vbNullString
If Button = vbLeftButton Then
If BoolIsElementBeingDraggedFromCanvas Then
Call MoveTool(X, Y)
If PreviouslySelectedToolOnBoard.IsLinked Then Call MoveLinks(X, Y)
End If
ElseIf Button = vbRightButton Then
'Blah.....blah...blah...
The MoveLinks method is code listed below:
Code:
Public Sub MoveLinks(ByVal X As Long, ByVal Y As Long)
If PreviouslySelectedToolOnBoard.IsLinked Then
If PreviouslySelectedToolOnBoard.NumberOfLinks > 0 Then
For LngCounter = 0 To UBound(PreviouslySelectedToolOnBoard.Links)
MoveToEx frmCanvas.picCanvas.hDC, PreviouslySelectedToolOnBoard.Links(LngCounter).ToPoint.X, _
PreviouslySelectedToolOnBoard.Links(LngCounter).ToPoint.Y, _
ByVal 0&
SetROP2 frmCanvas.picCanvas.hDC, R2_NOT
LineTo frmCanvas.picCanvas.hDC, PreviouslySelectedToolOnBoard.Links(LngCounter).FromPoint.X, _
PreviouslySelectedToolOnBoard.Links(LngCounter).FromPoint.Y
MoveToEx frmCanvas.picCanvas.hDC, PreviouslySelectedToolOnBoard.Links(LngCounter).ToPoint.X, _
PreviouslySelectedToolOnBoard.Links(LngCounter).ToPoint.Y, _
ByVal 0&
SetROP2 frmCanvas.picCanvas.hDC, R2_NOT
LineTo frmCanvas.picCanvas.hDC, X, Y
With PreviouslySelectedToolOnBoard.Links(LngCounter)
With .FromPoint
.X = X
.Y = Y
End With
End With
With PreviouslySelectedToolOnBoard.Links(LngCounter)
With .PreviousPassThroughPoint
.X = X
.Y = Y
End With
End With
Next LngCounter
End If
End If
End Sub
Lines Moving Around On My Form
Here is a real strange thing that happens. I have a form where there are a few collumns being totaled. under the cells I want to total I have drawn a line, and put the totals under the line like this
1 2 3
2 3 1
________________
total 3 5 4
Sometomes when I come back to my form, the lines are moved and sized much shorter. I have to reposition them. Anyone heard of such a thing?
Moving Lines Within A List Box
hello,
i have a list box and i want to move some lines in it, but here is the catch;
i built the list like this:
i have a 'brake' line and then some other lines starting with " " (4 spaces). it serves me as groups.
what i want to do is move the entire groups up and down.
i keep failing on managing to do this..
it looks something like this:
brake1
line1
line2
line3
brake2
line1
brake3
line1
line2
i have between 2 and 10 brakes and as many lines between them.. (they also have unique names; not 'brake' and 'line').
also,
the up and down buttons are only enabled when i'm on a brake.
they are disabled seperatly when i'm on the first or last brake.
when i click on my up button (for example when i'm on brake3);
it will replace brake2 and look like this:
brake1
line1
line2
line3
brake3
line1
line2
brake2
line1
and so is with the down button (on brake1);
brake3
line1
line2
brake1
line1
line2
line3
brake2
line1
after this, i also want to be able to move the lines up and down, but to disable the buttons when i'm on the first line and the last line.
(i only use 2 buttons; 'CmdUp' and 'CmdDown')
i use this line to tell when it's a line and not a brake;
if left$(list1.listindex,4)=" " then blahblah..
i only managed to get the brake (any) to become the first of the list, and not even go down...
help?
thanks in advance..
Stop A Moving Image Drawing Over Other Lines...
I have the following code which moves a little image control across the form, but what happens when it moves across slowly is it sort of half draws over lines that I have on the form....how can i get it so that it doesnt draw over the other lines and leaves them intact....so that it doesnt leave this kind of trail.....
VB Code:
Private Sub Timer1_Timer()If Image2.Left < 9240 Then Image2.Left = Image2.Left + 1'only move the picture one space over if it isnt alreadt at the desired locationEnd IfEnd Sub
Code For Moving To The First Blank Cell In A Worksheet; Moving Left,right,up Or Down
I have created an application form as a userform in Excel. I need to send the data entered into my text boxes when the program runs to separate excel cells in a worksheet.
My problem is I can use code that will send the textbox entry to a specific cell eg. If my textbox is named Surname I can say
range("a5").value = surname but if I do that when I run the programme to enter the next record for someone else the first record will be overwritten.
I NEED A CODE LINE THAT WILL TAKE ME TO THE FIRST EMPTY CELL AND ALLOW ME TO MOVE DOWN OR TO THE LEFT OR TO THE RIGHT
Reading Certain Lines Of Files And Outputting Those Lines
This is what I am trying to do and I think I am going about it all wrong.
I am trying to read a log file (ascii) and only want to read in certain pieces of information (e.g. a failed request for a web page) and then I want that information written to a new file.
I wont even attempt to post thw code I have trying to work with, if someone can give me some pointers of post some example, I would really appreciate it.
Hmm - New Lines Arent Read As New Lines By Vb In A File
Heres the situation
im using urldownloadtofile to download a text file from the internet onto the harddrive. although the textfile on the net has 5 items, each on a single line, when i use that function the file saves as 5 items all on a single line.. and where a new line is supposed to be, i see a "box" in notepad..
needless to say, when i try to load the file into an array using Line Input, all 5 items are on a single array number, instead of one item in each array number..
heres what i mean..
text file online:
a
b
c
d
e
text file when downloaded to hd:
a[]b[]c[]d[]e
the box is interesting, if i copy the entire text from the file on my hd and paste it, they paste with all 5 items on seperate lines..
my question is, how can i load a[]b[]c[]d[]e with one item in each array with VB? line input wont work cause itll store a[]b[]c[]d[]e in one string
Read Lines And Count Lines From Txt File - Thank Ye All
hello again
im back for some more help, so i hope you guys can.
ive had a quick search on the forums for this but cant find anything that helps, so heres my problem:
i have this code:
Code:
Function random2()
Dim lines As Integer
Dim current As String
lines = 0
Open "C:files.txt" For Append As #1
Do While Not EOF(1)
Line Input #1, current
lines = lines + 1
MsgBox (current)
Loop
Close #1
txtFILE = lines
End Function
but that code doesnt work, it does count the lines at all, i get no msgbox's, no count, no nothing.
any help would be much appreciated.
thanks.
Primary_Slave
----------------------------------------------------------------------------------------
I'm all wrapped up in my binary blanket and I'm coding on late into the night
----------------------------------------------------------------------------------------
Edited by - Primary_Slave on 11/4/2004 9:46:42 AM
Moving Balls To Moving Images??
Please take a look at this as it is related to my question
Thread
is it possible for the create images to be an image type that is already drawn?
How Many "visible" Lines (including Wrapped Lines) Are In A RTB?
I know I can get the "total" number of lines (including wrapped lines) in a RichTextBox by doing the following:
Code:SendMessage(RichTextBox1.hwnd, EM_GETLINECOUNT, 0&, ByVal 0&)
but, how can I get the total number of "visible" lines (including wrapped lines) in a RichTextBox only (ie: only the lines currently able to be seen in a RTB)?
Edited by - uncletr on 1/16/2007 5:27:03 AM
Lines Events Lines Ocx
I would like to create lines with vb6 and to change them when my program is runnig, but "line1" doesn't have any events, not mouse_clickmouseover.
I'm looking for solution for that problem or lines ocx instead.
Hope for answers...
Selecting
That was the only title I could think of to call this trend.
What I want to do is create a way to select between 30 or so diffrent things (products, names, etc..) in VB6. I want to have all of them showing in a grid format and the user selects them by using the arrow keys to move around and the enter button for final selection.
The best example of this I can think of is if there was a Excel spreedsheet with data in a 10 x 10 matrix (10 column , 10 rows).
You can move around the data with the arrow keys, with each cell holding it's own data that can be selected.
Selecting
I am making a semi-strict tile based game and recently i figured out some code and now there is more than one person you can control, like a real time strategy. i had to put in a way of selecting which one would move when you clicked so i did the code but it doesnt work properly and i dont see why. instead of having to click on the guy like i wanted,you have to click a square either left or up of him. Please help. Here is the code:
____________________________________________________
****************************************************
'mousedown procedure
If Button = 1 Then
For a = 0 To Universe.TotBeings
If Int(Being(a).X / 67) = Int(X / 67) And Int(Being(a).Y / 64) = Int(Y / 64) Then
'if you click on the man then run selection routine
Universe.Selected = True 'is anyone selected
For b = 0 To Universe.TotBeings
Being(b).Selected = False 'unselect everyone
Next b
Being(a).Selected = True ' select only being(a)
'draw square around selected thing
Form1.Line (Being(a).X + 10, Being(a).Y + 10)-Step(47, 44), QBColor(14), B
'draw thing over square so its in foreground
Call DrawSquare(Being(a).X, Being(a).Y, Being(a).Type, Being(a).Icon, Being(a).Row)
Else 'if you click away from beings then deselect everything
For c = a To Universe.TotBeings
Universe.Selected = False 'nothing is selected
Being(c).Selected = False 'unselect thing
Call MapMove(c) 'erase square
Next c
End If
Next a
End If
Universe.Selected = False
End Sub
____________________________________________________
Selecting Where You Are
Hi,
I am an amateur. I would like to check some text that is on particular lines in a word document. I don't know exactly how the Selection object works, but what I would like to do is this:
I want to go to a specific line using the GOTO command in word and, once I get there, I want to check to see if there is one of several possible words there (I will be using regular expressions). When you maneuver, using GOTO in a word document, to a specific line, will the selection be automatically updated to contain the words in that line ?
I want to be able to find out what's on the line I go to and see if it's what I expect.
Thanks for any help you can offer.
tmanning
Selecting Twice?
Ok In my menu its a checked menu, I want the people to be able to uncheck it, or just if they click it a second time, it will execute another code. Please help im a totally newbie.
This is my code
Private Sub mnuBackGroundBlack_Click()
'Write Back Color to .INI file
WritePrivateProfileString "Back Color", "Black", "1", App.Path & "sample.ini"
Form1.BackColor = Black
End Sub
I want the it to give me this if they select it again :
WritePrivateProfileString "Back Color", "Black", "0", App.Path & "sample.ini"
Just to return me a value of 0 If they uncheck it.
*another question how come by default its already checked? I just add it to the menu editor, by selecting checked. But its always checked when I run my program.
thanks
Selecting On ADO
Hi Folks,
Is there a way to use a SELECT Statement from SQL on an ADO Recordset in VB?
Thanks,
-Sir Henry
Selecting A Tab
I want to delete a row in excel using vb. But first I need to select the worksheet (tab) in excel. But every time my code hits a certain line it gives me an error: Subscript out of range.
[highlight=VB]
Dim objXL As Excel.Application
Dim objXLWrkBk As Excel.Workbook
Dim objXLWrkSht As Excel.Worksheet
Dim lngToDelete As Long
Set objXL = CreateObject("Excel.Application")
Set objXLWrkBk = objXL.Workbooks.Open(Me.txtCalcSheetLink.Text)
Set objXLWrkSht = objXLWrkBk.Worksheets(Me.txtTPos.Text)
objXL.DisplayAlerts = False
objXL.Visible = False
'snatch which component is going to be deleted
lngToDelete = Me.MSHFlexGridTC.TextMatrix(Me.MSHFlexGridTC.Row, 1)
objXLWrkBk.Activate 'set the work book as active
objXLWrkSht.Activate 'along with the work sheet
objXLWrkSht.Range("A6").Activate 'activate the component column
'can we find the component?
If (objXLWrkSht.Columns("A").Find(lngToDelete, objXL.ActiveCell, , , xlByRows, xlNext).Activate) = True Then
'yes we found the component, delete in excel first
objXL.Rows(objXL.ActiveCell.Row).Select
objXL.Selection.Delete Shift:=xlUp
Else
'cant find it
End If
objXLWrkBk.Close SaveChanges:=True
objXL.Quit
Done:
Set objXLWrkSht = Nothing
Set objXLWrkBk = Nothing
Set objXL = Nothing
Exit Sub
Err_Handler:
MsgBox Err.Description, vbCritical, "Error #: " & Err.Number
Resume Done
[highlight=VB]
It dies right in the beginning on this line:
VB Code:
Set objXLWrkSht = objXLWrkBk.Worksheets(Me.txtTPos.Text)
I just want to make sure in my excel app that this tab has the focus so that I can process the if condition to find the row to be deleted:
VB Code:
If (objXLWrkSht.Columns("A").Find(lngToDelete, objXL.ActiveCell, , , xlByRows, xlNext).Activate) = True Then
Can anyone point out my mistake.
Selecting Sub
Is there a way to choose what subroutine to run by having its
name in a textbox/variable/etc...?
EXAMPLE:
Code:
txtRun.text = "MyCode"
Private Sub cmdRun_Click()
'****** run selected sub ******
End Sub
Public Sub OtherCode()
msgbox "OtherCode"
End Sub
Public Sub MyCode()
msgbox "MyCode"
End Sub
Selecting
how would i get it so that when you check a checkbox, somthing gets added to the code, and when you deselect it, it gets taken out?
Selecting All
What's the actual code to select all the text in a combobox?
Selecting Name, Etc.
I am trying to create a simple program for my own personal use. I am using Netscape 4.7, and I want to be able to run one EXE, open Netscape, have it select my name from the profile list, and then launch all the sites I have pre-listed in Websites.txt in new windows.
I already can do the last part. I have code that launches the sites in new windows, but I'm not sure how to make it select my name and press login.
I would prefer not to use Sendkeys.
Any thoughts or suggestions would be welcome.
Selecting A Specified TAB
Hello all,
Could someone tell me how to select a specified tab (from a tab strip)in
software ?
Kind regards,
Darren Logan BSc(Hons)
Development Engineer
Selecting
I use Excel 2000 a lot and I'm working on automating a workbook lets say cell A1 is used for "building location" and the user enters ABG (a work location) and I store the email address of each location in lets say Z1:Z10. How do I insert the correct email recipient address for the location picked in the following
Thanx in advance
ThisFile = Range("A1").Text
ActiveWorkbook.SaveAs Filename:="C:Test" & ThisFile, FileFormat:=xlNormal
ActiveWorkbook.SendMail "landonmw@cox.net", "Subject of message goes here"
Selecting A Row
hi
i am using MSHFlexGrid
to display a particular database
now when i search a particular reocrd in the database
that particular row in the flexgrid should get selected which is displaying that record
i am using byrow selection mode
thanx 4 ur help
Selecting Everything By TAB Key
Hello,
I am trying to TAB to one text box from another and I want whole of the test to be selected when I TAB into the next field,
Any Help,
Thankx in advance
Selecting Certain Line
Hello.
Anyone know how I would go about selecting a certain line number from a text file?.
I open a text file (it has 10 lines) and display it in a richtextbox.
How would I go about making it only show the 4th line?
Thanks
Selecting A Directory
I am writing code to read a file extract information from the file and then write out the extracted data. I want to specify an output directory (the filename will be generated automatically, based on the input file name). Is there a way to choose a directory using the common dialog control? (I'd also like to be able to determine if the directory chosen is writable.)
David Gerstman
Selecting Colorrange
Hi there,
I'm working on a program which needs to replace some colors.
The picture is loaded into a picturebox and I try to replace all the red
colors.
This works, but only for the colors that I add to replace.
Is there anyway for a certain 'loop' through a color range?
Let say I start at &HFF And finish at &H605F4 (or something like that)
I want to replace all the colors 'Inside' those two colors.
Does anyone know a trick how to do this?
Thanks in advance,
stevie52
Selecting A Row In Flexgrid
Hi,
I have a flexgrid with over 500 rows in it.
On my form, only around 20 rows are visible at any time.
Once the data has been loaded into the flexgrid, I want the software to automatically scroll to and select the row containing the biggest number (from column 2).
eg flexgrid looks something like this:
col 1 col 2
1 4
2 8
...
300 46347646
301 5
...
500
so i want the code to select and make row 300 visible.
How do I do this?
thanks
pete
Selecting The Right Answer!
hi, can some1 help me, i want to be able to set it so that when a user clicks on a question they have a max of 3 attempts, if they fail it will be game over, otherwise it will be the next question.
this is wot ive attempted so far:
Private Sub Label1_Click(Index As Integer)
Dim intMaxAttempts As Integer
Dim intAttempt As Integer
Dim intPass As Integer
Dim strAnswer As String
Dim strRightAnswer As String
Dim bCorrect As Boolean
Dim intReply As Integer
intMaxAttempts = 3
RTS Question (selecting)
I am thinking about a way to select building / vehicles in my game im gonna make in dx7. Im thinking about using intersectrect i tested in a test program and it works but im not sure if there is a better more effecient way of doing it ?
Selecting Several Cells
how can i select several cells from this code? - obExcel.Application.Range("A14").Select doesn't work
please help
Code:
Option Explicit
Dim obExcel As Object
Private Sub Command1_Click()
obExcel.Application.Range("A1").Value = "87"
obExcel.Application.Range("A1: D4").Select
End Sub
Private Sub form_load()
Set obExcel = OLE1.object
End Sub
Selecting Cells
hello everyone,
i've writing a macro in excel. i do a search with this function:
Code:
Set found2 = Sheets(strDataSheetName2).Range("a1").EntireColumn.Cells.Find("ref number", , xlValues, xlPart)
Once that cell has been selected how would i make it select the cell bellow and then the cell 4 to the right.
can anyone give me any ideas.
thanks for the help.
Selecting Cells
hello,
i'm writting aprogram that selects different cells in excel. this is all automated from vb. the user can click different buttons to select different columns. when a user clicks a button the code that is needed is put into a text box, so the user can get an idea of what they are doing. this is then used in the vb code.
eg if button the "a" is pressed
a1:a8 is put int the text box. its then used in the code like this:
Range(txtRangeSelect.Text).Select
i also have a function figures out how many rows are full in the table and one that figures out how many columns are full. these are called:
rowsfull
columnsfull
this all works fine. the last bit i'm trying to do is to select all the data.
when i click a button this is put in the text box:
Cells(1, 1), Cells(rowsFull, columnsFull)
therefore this is usedin the code
Range(txtRangeSelect.Text).Select which is
Range(Cells(1, 1), Cells(rowsFull, columnsFull)).Select
but it does not work.
its not the functions because i know they work.
can anyone see where i'm going wrong.
thanks a lot
Selecting A Section
Having established what the current section is using Selection.Information(wdActiveEndSectionNumber) can anyone please point me in the general direction of how to actually select all of the text in that section? I can't find a suitable method anywhere, but it must surely be possible?
Selecting Nth Records
HI
Is it possible to select (or make a table of) every Nth record in a Access table?
thanks in advance
Selecting Used Cells In A Row
how do you select just the used cells in a row?
eg: these are 5 cells:
red blue green blank blank
is there a way to just get the 3 colors?
Selecting Only A Few Rows In XL
Hi All!
Could someone please tell me how to select a specific number of rows?
I have a column of 20,000 integers in ALMOST consequtive order. The maximum deviation between my values and the row-index increases until it reaches to about 3000, at the end of the column.
I am conducting a search in my column.
I want to SPEED UP the SEARCH, which can take up to 5 seconds when searching items in far down the column, by starting a search only at aproximately 3000 rows FURTHER UP the column.
I am using the "selection.Find".
this is NOT good:
Cells(4, excelcolumnsearch).EntireColumn.Select
Thanks for any help you can provide...
Alex Skafidas
Selecting Other Workbooks
I need to know if there is a way to select a range of cells in a seperate workbook from the current workbook that I am in.
EX.
I have a workbook called OrigKK and a string variable named MCSbody$ in this workbook.
MCSbody$ needs to select a range of cells in a seperate workbook.
Hope all of this makes sense
Thanks
Know someone that owns a child care business. Go to www.kidkeeper.net. It will help them greatly
Selecting Rows
i know how to link a text box to a certain cell in excel, but how do i make a text box link to a certain row if the row numebr plus one or the row number is given? also, how would a make an item selected from a combo box give values in other cells
i.e.
say if it were a baseball player list in the combo box and you selected a player, how would you make the batting average and number of strike outs appear in the same row but different cells? would you have to use if-else statements? or would you have to make a list of stats in another sheet and link it to the first sheet via if-else statements?
thanks
Selecting A Specific Tab
Hi,
I'm trying to select names from a worksheet (Column A) and match each of these names against a second workbook. The second workbook has several tabs with each one respresenting the name of a person from column A.
For example; Column A has the names Smith, Jones, Prior, Ryan
I would like the macro to select each name and open the open that persons tab in the second workbook. The code would select Smith and search for the tab with the name "Smith".
The code I have so far is very crude and I can't get it to work. I would greatly appreciate any help in solving this problem.
This is what I have so far;
Public Sub FindTab()
Dim TabName As String
Dim EmpName As String
Dim ReturnValue As Integer
EmpName = Range("b1").Value
TabName = "='C:[Workbook B.xls]" & EmpName & "'"
Range("c2").Value = TabName & "!A1"
End Sub
Thanks very much.
|