2 Questions About Moving Objects.
Hi. I am new to Visuall Basic but not also to programming.
1)I have this function function:
Code: Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 32 Then ...
When i have the right arrow key pressed a picture keeps moving. But it stops moving when i hit another key, although the right arrow key is still pressed. How can i do that so that the picture will keep moving when the right arrow key is pressed, no matter if meantime i press other keys?
2) I want to make a picture or shape to start moving everytime a particular key is pressed. I can do this, but if the user press the key twice, the picture starts moving and then ( when they press the key for the second time ) it stops to move, goes to the beginning position and then starts to move again( from the beginning ). But i want the two pictures/shapes to move at the same time. How can i do that? And the user can hit the key as many times as they want. If he hits the particular key 4 times, then four pictures/shapes will start moving from a particular position ( but in different times; every time he press the key a pictures starts to move, if it takes them 5 second to hit the key for the second time, then the second picture will start to move after 5 seconds from the first one. Finally, both of them will move - but the one will be ahead ).
thanks in advance
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Help With Moving Objects
In my game, you can move objects around the playing field by using various keyboard keys (arrow keys, enter and space). This works fine. However, whenever I put a text box, command button, or anything else on my form, I can't move anything around....unless I disable the other objects. Is there a way around this?
Moving Objects
hi, im currently making a game.
for 1 part of the game, i have an image and it automatically moves
down + right with a timer. here the coding for it:
Image2.Move Image2.Left, Image2.Top + 40 ' Move Down
Image2.Move Image2.Left + 20 'Move Right
when i press 'the space bar', the 'Image2' moves up + right. heres the coding for it:
Image2.Move Image2.Left, Image2.Top - 40 'Move Up
Image2.Move Image2.Left + 40 'Move Right
i got this portion of the project done but when i press the space bar, it doesnt move 'instantly'. instead, when i press and hold down the space bar, it moves up + right, stops, then finally moves up + right. i would like for it to move instantly and smoothly when i press the 'space bar'
i think this problem may be because when i press the space bar, the image is moving down at the same time, so it kind of "fight" the push of it.
also, if anyone can help me to get this to work for the 'mouses click' instead of 'spacebar', it would also be appreciated but i dont really care.
can anyone help?
thanks very much.
Moving Objects
I know there are a few threads on things like this, I have seen them befor but I can't seem to find them. It was a few weeks ago that I last saw them.
I have a circle on the form and I want to be able to move it up if I press up arrow down if I press down arrow and so on, if i do this a few time with different things I could learn to move sprites. Any help please?
A Little Help {moving Objects}
sorry im really really new to this site but by the looks of things it kicks major buttooooooocks sooooo i just want a little help
ive been into game programming for a while but i aint used VB that long only about 3 weeks ive made a few simple problem programmes but nothing amazing
just to start off cos i am really new to this is there a thread which u could introduce me to to teach me how to move something around a screen because i intend to make an rpg but that will take alot of work so anything u can do for me will help me greatly.
well anyway im 16 m from wales uk and am doing a college course on computing (including VB) but we do boring stuff so theres no point in going there
thanks for all replies
Moving Objects
Am trying to do simple animation with several objects. The stuff moves as intended but not at the speed I would like. I have a several lights that sequence in the timer1 sub. Also during one of the sequences an object is to move across a page. Here is the code for the start of the object moving across the page:
Code:
Private Sub Timer1_Timer()
Case imgYellow 'Main Red, Side Green for25 seconds
Timer1.Interval = 4000
imgMain = imgRed(1)
imgSide = imgGreen
imgMain = imgRed2
If picHolder.Visible = True Then
Select Case imgSide.Picture
Case imgSide.Picture
imgSide.Picture = imgGreen
Do While picHolder.Left > 0
picHolder.Move picHolder.Left - 0.6
Loop
End Select
End If
end sub
If the picholder.left value is less than 0.51 the program hangs. And 0.51 is too fast.
Any help is appreciated.
Kim
Moving Objects Help
Please could someone help me this is my code for a moving image
Public Sub movUp()
imgsnail.Picture = imgsnail.Picture
imgsnail.Top = imgsnail.Top - 100 'Up'
The MovUp stands for move up; it works however there are three more lots of this code one for moving right, left and down. Here is my problem once you have moved up and then either right, left or down the image will then not move up. Well it will just in the last position. For example if I move right then try going up the image will move up but will still be facing right. Please could someone tell me if there is anything wrong with this code, I think it may need modifying but I am not sure how.
Thank you Helen
How To Tell When 2 Moving Objects Have Met
Hey, im making a game for school. I need it so that if an object hits the rocket something will happen.
For example I have a picRocket and a picObstacle1
picObstacle1 just goes from side to side across the form and the object of the game is to get the picRocket past the picObstacle1 using the arrowkeys to fly without getting hit.
What im asking is, how can I tell when the Rocket has hit the obstacle while it is moving?
Moving Objects
How do I make a object disapear when it hits nother object and then set it to appera in another spot on the screen
Thankx
Moving Objects
How can I make a image move back and fourth and up and down??
Thankx
Moving Objects...
When you move an object (form, picturebox etc.) then a rectangle is displayed indicating where the object will be placed when the capture is released.
Is there any way you can change this rectangle using API?
I need this for a docking system I'm working on so that when the user drags a window over a specific area of my program the rectangle will change so that the user can see that if he releases the left mouse button the window will be docked at that position.
Did that make sense? And do you know if there is such an API?
Moving Objects
Im making a program where it randomly makes boxes that i want to fall from the top of the screen. I have it create the box with this code:
Dim ctlPB As Control
Set ctlPB = Controls.Add("VB.PictureBox", "PictureBox2", Picture1)
ctlPB.Top = 0
ctlPB.Left = Label4.Caption
ctlPB.Height = 375
ctlPB.Width = 255
'show the picturebox
ctlPB.Visible = True
End If
Label4 is just the random location at the top of the screen. Now what code would I do to make this now created box move down the screen.
Vb Moving Objects?
Hi,
I have created a basic maze, the user uses the arrow keys to navigate between the maze walls collecting items ( basically a rip off of pac-man ). Anyway, i have "shpMonster", i want to create a set path for it to travel around the maze on, whats the best way to do this? Timers? Im new to this so im not too familiar with making an object move round a path constantly...
Thanks in advance.
Moving Through Objects
hi we all know about moving through objects in vb using tab, with the tabindex and stuff. but what about moving through objects with arrow keys? is this possible and if so can someone show me some code?
i don't even know if this is the right form i just assumed it would be something with API.
anyway thanks for your time.
Moving Objects
Hi there,
does anybody know how to move objects?
like a plane or an object?
i wan it say a random no. generated is 4
i wan this object to move 4 steps..
how can this be done?
has it got to do wif x, y corrdinates??
if i wan this object to move according to the random number generated..how can this be done also?
pls reply..thanks.
Moving Form Objects
Hi guys
I am trying to write a section of code at the moment that spawns up to 100 imagebox controls and places them as a matrix on the screen. I then need groups of these objects to move down, across, down then disappear. I have got as far as placing the matrix of objects on the screen but am having a hard time moving the objects.
My question is; what would be the best way to move the controls? I have tried doing for..next loops with changing the image1(x).top and .left and have used a pause function between each step but the code is very clumsy and I am getting lost in all the loops. Is there another method that I have overlooked? You'll have to forgive me if I am missing something basic. I am not a "newbie" but have been away from VB for some time.
Thanks in advance
Moving Objects Smoothly
I have found that moving a picture at a constant rate is somewhat jumpy even using bitblt. How can I fix this?
Moving Objects With Keyascii
I am making a game for my A-Level I.T project and need to know how to make an object move using the cursor keyas and Ascii code. Anyone know how to do this?
Randomly Moving Objects?
Ok i tryed a few searches but didnt find anything relating to this.
Does anyone know how i could move say and Image Control for example Randomly across a Form.
Lets say that Image1 is in the Middle of the form and will Move its way down to the bottom.
But then i need it to randomly position itself some else on the form and so on.
Any Ideas?
Moving Objects Across Screen
ok so i have a picture that i need to move across screen but it cant hit the sides of the screen or barriers that i make with other pictures.
i have no idea how i would go about doing this i dont necissarily want code but if someone could point me in right direction that would be chill
Moving Objects Over A Picture
Has anyone any idea how to create a small app that lets you move objects around on a picture while keeping them all individual?
I am trying to create an app that lets you select from a series of small images and drag them onto a large image for positioning/sizing. Each small image should remain individual and resizeable until you click 'Apply' when they will become part of the large image.
Thanks, i dont know if its possible in vb without writing each line of code to do it or if theres a component that does it for you.
Cheers
Help: Moving Objects After Buildtime??
any one know how i would move an object ( a picrure box) on a form, and be restricted to certin gids/other objects(label or a frame)?????
_________
|x|p|p|_|_|
|_|_|p|_|_|
|_|_|_|_|_|
|_|_|_|_|_|
like this if x was the object to move aroubd and p is the path it can move in; and cant move over other objects.
Moving Objects In Arrays (vb.net)
This is probably a stupid question but me and my friend are new to this... Haha.
I'm making some program for class with my friend and we have all these items moving from left to right, then once reaching the edge changing their vertical direction so they are moving from right to left, and then when the reach the edge they move down a bit and then the process repeats using an array. Then, we have a random number select one of the objects in the array whenever the timer reaches a certain number, and move just that item downwards, HOWEVER, we do not want to move the 'selected' item left to right anymore. We want it to stay in the same position that it started moving downwards from. We have tried MANY different things, and we cannot seem to get it to work. All that we have got is the moving downwards of the one object to happen, but for some reason we just cannot get it to stop moving left/right.
We were thinking that it might work if you can remove an object from an array but our teacher said that you can't do that... So yeah... We really are stuck now and are therefore using the weekend to search for a solution!
Any suggestions/ideas are welcome...
I hope this made sense. If any questions or clarification is needed feel free to ask and I'll do my best to explain.
Moving Objects To Cells On MSFlexgrid?
I've made a form with a 25 * 25 cell msflexgrid, on the form is a small image, how easy is it to move the image onto a set of cells, by either draging and dropping the image, or clicking on the cell and tell the image to move there, then afterwards telling me where the image is?
Moving Objects To The Mouse Cursor?
I am making a diablo style RPG and I need to implement a mouse system like diablo where you click somewhere and your character will move towards it.
All I need to know tho is how to make objects move to the mouse cursor position.
And I was also wondering how I can use the arrow keys on the keyboard to make them do commands.
How To Detect If Moving Objects Touch Each Other
Hi,
I'm practicing with object animations using a timer. My particular object are just basic shapes (an oval and a circle) that move around within the form.
I'm trying to make the program detect when the objects come in "contact" with each other, so that I can ask for other things to happen. What I've basically done to detect a contact is checking for the Left,Top "coordinates" for each object and also considering each objects' "perimeter" coordinates.
I don't know, but that may not seem practical to do, especially when Shape1 moves and doesn't take in all the possible ".top" values (like when moving vertically) because it's more practical to make it "skip" in INTERVALS to make it seem like it's moving fast up the form. And even if I only consider the ".top" value when detecting contact, it may not even be possible to detect any contact at all when the ".top" value of Shape2 is contantly (moving horizontally) between one of the ".top" value intervals of Shape1.
So, in normal "playback," it may look like that the shapes collide, but it's never detected.
So, is there any practical way to dectect object "collision" when they are moving?
Also, I use different timers for each shape so that I can make one of the shapes stop moving when there is a collision. Tell me if this is an inefficient use of the timer.
I would appreciate any reply. Thanks.
Moving/Resizing Objects At Runtime?
Does anyone have code example of how to select an item at runtime and have it selected with resizer handles around it and allow resize/moving at runtime?
Thanks!
Moving Objects With The Arrow Keys
My cousin is working on a VB program for school and is wondering how to make it so that when he has "compiled" (I don't know a lot about VB, so I don't know how you go about doing things) the program, he can use the arrow keys to move an object. He really needs to know how to do this fast, because it was due a couple of days ago. Please respond ASAP.
Darkwater3@hotmail.com
Moving Control Element Objects On Form
hi there i really need to know the answer to this since im leaving 2morrow until thursday....
i have a form. this form adds components using the index array at runtime. is it possible that when they are added to the form, for the user to click and drag those components on the form and then detecting its x,y co-ordinates?
Thanks
Moving Objects/controls Inside A Picturebox!?!
I need to move several (LOADS OF) objects (labels/textboxes/etc) inside a picturebox quickly and easily....... is there anyway of doing this without deleting the objects and re-creating them inside the picturebox?
...and I need them actually inside the picturebox, not just hovering on top as if it looks like they're inside it!
Any help would be great!
Thanks in advance!
Best Thing To Use For Making Moving Objects In A Game
I am creating a snake game . it works great but once the snake gets longer it's "segments" start to look flashy (disapearing pieces for a minor second) i ofcourse dont want to have this. the segment is made from a picture in a picturebox and so is the playfield where it is located in autoredraw is turned on, so what should i do about it?
Bunch O Timers - Moving Objects - Bounce Off Screen Edge
I'm sure it's been covered before . It's not that hard to do
yet I have issues . This is simple , Move the Object around the screen . The problem lies when it's moving to the right hand side . It seems to hit the wall then go straight up , yet on the left it works fine . I fail to see the error in my code and was hoping that you would have a look . The code is below .
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_GETTEXT = &HD
Private Sub cmd_StartRecord_Click()
End Sub
Private Sub cmd_StopRecording_Click()
Sleep 4000 ' 2000 milliseconds = 2 seconds to delay
Timer1.Enabled = True
retval = SetCursorPos(0, 0) ' move the cursor to top left corner
End Sub
Private Sub cmd_Start_Click()
Sleep 4000 ' 2000 milliseconds = 2 seconds to delay
Timer1.Enabled = False
retval = SetCursorPos(0, 0) ' move the cursor to top left corner
End Sub
Private Sub Command1_Click()
End Sub
Private Sub cmd_Stop_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
'Call the Formsontop function
'USAGE: Call formsontop(Me ,True ) -ONTOP MOST
' Call formsontop(Me ,False ) -NOT TOP MOST
Call FormsOnTop(Me, True)
'Set Initial Settings
Steps = 0
'Set the Steps Caption to the amount of steps
lbl_Steps.Caption = "Steps (" & Steps & ")"
Recording = False
Playing = False
'Get the screen Resolution
Dim x, y As Integer
x = Screen.Width / Screen.TwipsPerPixelX
y = Screen.Height / Screen.TwipsPerPixelY
Label3.Caption = "Screen Width =" '& x '& " TwipsPerPixel"
lbl_X.Caption = x
Label4.Caption = "Screen Height =" ' & y '& " TwipsPerPixel"
lbl_Y.Caption = y
Timer2.Enabled = True ' This captures the links
End Sub
Private Sub Timer1_Timer()
If IsOnScreen Then
'Call MoveMouse(GetX + 10, GetY + 10) 'Change Location of the Current Cursor
Dim retval As Long ' return value
retval = SetCursorPos(GetX + 10, GetY + 10) ' move the cursor
'//Updatet the text boxes
txt_CurrentX.Text = GetX
txt_CurrentY.Text = GetY
Me.Refresh 'Refresh the form1
If GetAsyncKeyState(vbLeftButton) Then Debug.Print "Left Button"
If GetAsyncKeyState(vbRightButton) Then Debug.Print "Right Button"
If GetAsyncKeyState(vbMiddleButton) Then Debug.Print "Middle Button"
If Not IsOnScreen Then
Putonscreen
End If
End If
End Sub
Public Sub TogglePlayrecord()
'This toggels the play and record booleans
If Recording = True Then
Playing = False
End If
If Playing = True Then
Recording = False
End If
End Sub
Private Sub txt_Steps_Change()
End Sub
Public Function IsOnScreen() As Boolean
'Get the screen Resolution
Dim xscreen, yscreen As Integer
IsOnScreen = True
xscreen = Screen.Width / Screen.TwipsPerPixelX
yscreen = Screen.Height / Screen.TwipsPerPixelY
xHold = GetX
yHold = GetY
If xHold + 20 >= xscreen And yHold + 40 >= yscreen Then IsOnScreen = False
End Function
Public Sub Putonscreen()
Dim retval As Long ' return value
retval = SetCursorPos(0, 0) ' move the cursor to top left corner
Call Flash
End Sub
Public Sub Flash()
Dim i As Integer
For i = 1 To 50
SendKeys "{NUMLOCK}"
SendKeys "{CAPSLOCK}"
SendKeys "{SCROLLLOCK}"
DoEvents
Next i
SendKeys "{f5}"
End Sub
Private Sub tmr_down_Timer()
If Not IsOnScreen Then Putonscreen
If Not Istolow Then
'Call MoveMouse(GetX + 10, GetY + 10) 'Change Location of the Current Cursor
Dim retval As Long ' return value
retval = SetCursorPos(GetX, GetY + 10) ' move the cursor Down
'//Updatet the text boxes
txt_CurrentX.Text = GetX
txt_CurrentY.Text = GetY
Me.Refresh 'Refresh the form1
If GetAsyncKeyState(vbLeftButton) Then Debug.Print "Left Button"
If GetAsyncKeyState(vbRightButton) Then Debug.Print "Right Button"
If GetAsyncKeyState(vbMiddleButton) Then Debug.Print "Middle Button"
If Istolow Then
'Go Up
tmr_up.Enabled = True
tmr_down.Enabled = False
End If
End If
End Sub
Private Sub tmr_left_Timer()
If Not IsOnScreen Then Putonscreen
If Not Istoleft Then
Dim retval As Long ' return value
retval = SetCursorPos(GetX - 10, GetY) ' move the cursor left
'//Updatet the text boxes
txt_CurrentX.Text = GetX
txt_CurrentY.Text = GetY
Me.Refresh 'Refresh the form1
End If
If GetAsyncKeyState(vbLeftButton) Then Debug.Print "Left Button"
If GetAsyncKeyState(vbRightButton) Then Debug.Print "Right Button"
If GetAsyncKeyState(vbMiddleButton) Then Debug.Print "Middle Button"
If Istoleft Then
'Go Right
tmr_left.Enabled = False
tmr_right.Enabled = True
End If
End Sub
Private Sub tmr_right_Timer()
If Not IsOnScreen Then Putonscreen
If Not Istoright Then
Dim retval As Long ' return value
retval = SetCursorPos(GetX + 10, GetY) ' move the cursor right
'//Updatet the text boxes
txt_CurrentX.Text = GetX
txt_CurrentY.Text = GetY
Me.Refresh 'Refresh the form1
If GetAsyncKeyState(vbLeftButton) Then Debug.Print "Left Button"
If GetAsyncKeyState(vbRightButton) Then Debug.Print "Right Button"
If GetAsyncKeyState(vbMiddleButton) Then Debug.Print "Middle Button"
If Istoright Then tmr_left.Enabled = True And tmr_right.Enabled = False
'Go Left
End If
End Sub
Private Sub tmr_up_Timer()
'If it's not on the screen put it on the screen
If Not IsOnScreen Then Putonscreen
Dim retval As Long ' return value
If Not Istohigh Then
retval = SetCursorPos(GetX, GetY - 10) ' move the cursor up
'//Updatet the text boxes
txt_CurrentX.Text = GetX
txt_CurrentY.Text = GetY
Me.Refresh 'Refresh the form1
If GetAsyncKeyState(vbLeftButton) Then Debug.Print "Left Button"
If GetAsyncKeyState(vbRightButton) Then Debug.Print "Right Button"
If GetAsyncKeyState(vbMiddleButton) Then Debug.Print "Middle Button"
If Istohigh Then
tmr_up.Enabled = False
tmr_down.Enabled = True
End If
'Go Down
End If
End Sub
Private Sub txt_CurrentX_GotFocus()
Me.SetFocus
End Sub
Private Sub txt_CurrentY_GotFocus()
Me.SetFocus
End Sub
Public Function Istohigh() As Boolean
Dim maxUp As Long
Dim CurrentUp As Long
Istohigh = False
CurrentUp = GetY
maxUp = 0
If CurrentUp - 40 <= maxUp Then Istohigh = True '
End Function
Public Function Istolow() As Boolean
Dim maxUp As Long
Dim CurrentUp As Long
Istolow = False
CurrentUp = GetY
maxUp = CLng(lbl_Y.Caption) ' this is Y of the screen
If CurrentUp + 40 >= maxUp Then Istolow = True '
End Function
Public Function Istoleft() As Boolean
Dim maxleft As Long
Dim Currentleft As Long
Istoleft = False
Currentleft = GetX
maxleft = 0
If Currentleft - 50 <= maxleft Then Istoleft = True '
End Function
Public Function Istoright() As Boolean
Dim maxRight As Long
Dim CurrentRightt As Long
Istoright = False
CurrentRight = GetX
maxleft = CLng(lbl_X.Caption)
If Currentleft + 50 >= maxleft Then Istoright = True '
End Function
Thank you ,
[]P
Moving An Object Questions
Ok I am making a game for a project that I have to do and I am having some difficulties the following are a few questions
1. The game consists of a snake that you move, I am trying to figure out how I can make another object dissapear when it collide into it that then re-appears randomly on the screen.
2. I want a segment to be added on to the snake each time it collides into this object and I want this segment to turn with the snake whenever the snake turns.
If anyone can help me out here I would really appreciate it !!!!
*Thanx*
2 Questions....Moving Active Cell And Counting
Okay, the first question
I have found a cell...now i just need to move 3 cells to the right and get that value.
How do I from a column, count how many of that specific number like
222
222
333
333
444
444
444
so 222 = 2
333 = 2
444 = 3
Any information would be greatly appreciated.
Questions: BitBit Moving, Walkmasks And Item Pickups.
Ok, so far have i quickly created a small program where a picture(the guy you control) moves instantly to the location of your click. Theres 3 things i must now:
1. How can i make my guy move slowly to the targeted location? not instantly.
2.How can i create walkmasks? Forexample if i create a tree, and i dont want my guy to walk right through the tree but around it.
3.How can i make my character pick up items? Forexample how can i make my guy get 10 score-points when he moves over an item, which in reality is a picture.
Edit*
I use BitBit.
This is not going to be a real game, iam just testing things out before i start creating a game.
Nothing is animated.
2 Questions: Dimming Objects And Negatives Vs Positive Counterparts
Two quick questions. Let's say I'm making a FileSystem Object. There are two ways of doing it. I can do this:
Code:
Dim MyObject as Object
Set MyObject = CreateObject(Scripting.FileSystemObject) 'or something like that
or I can do this:
Code:
Dim MyObject as FileSystemObject
Set MyObject = New FileSystemObject
I know that intellisense will only work with the latter, but is there any speed difference in declaring it as a FileSystemObject as opposed to an Object?
My second question is about using negatives in code. The two pieces of code here are equivalent:
Code:
Do While Not EOF(FileNumber) 'DoStuff
'and
Do Until EOF(FileNumber) 'Do Stuff
Is there any performance difference between the two? Another example is this:
Code:
Dim MyArray() as String
'Do stuff with the array
If (Not MyArray) = -1 then 'array isn't dimmed
or
If (Not MyArray) <> -1 then 'array is dimmed
Is there a performance difference, or can you just use either as suits the logic of the situation? Thanks,
Dan
Objects In Behind Other Objects Covering Up Objects Infront
I've been experimenting with direct 3d and I came across a snag. It seems that regardless of the z cordinate the objects are displayed in the order they are drawn. So if object1 is supposed to be behind object2 but is drawn after object2 object1 will actaully be drawn over object2. Is there a slick way around this problem.
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
Resizing Objects Bring To Front Other Objects In SSTab
Hi.
I've got a SStab object with 3 tabs. Each tab has one MSHFlexGrid.
These object are in a MDIForm Child.
When I resize the child form, i'll do this code:
Code:
'Consultas is a form
'every object started with Grid is a MSHFlexgrid
Public Sub FormConsultas()
On Error GoTo Erro
Consultas.SSTab1.Height = Consultas.Height
Consultas.SSTab1.Width = Consultas.Width
If Consultas.Width < 11925 Then Consultas.Width = 11925
If Consultas.Height < 8055 Then Consultas.Height = 8055
Consultas.GridFactESDDExp.Move 90, 600, Consultas.Width - 420, Consultas.Height - 2000
Consultas.GridAcordoHorasFech.Move 90, 600, Consultas.Width - 420, Consultas.Height - 2000
Consultas.GridAvisosCobrancas.Move 90, 600, Consultas.Width - 420, Consultas.Height - 2000
Erro:
Select Case Err.Number
Case 0
Case 384
Case Else
MsgBox Err.Number & " - " & Err.Description & " - " & Err.Source
End Select
End Sub
What happens is: after resizing the form, sometimes, the grid of the 2nd tab persist visible when tab 1 is selected.
What can explain this behavior, and how can I avoid this?
Thanks
Creating Business Objects Reports In Visual Objects
hi all
i want add business objects Universe in visual basic.
(universe is a query on source data base).
i want to access data from universe and i want to create report in vb. can u help me out.
regards and thanks.
james
For...Each With A Dictionary Of Objects; Send Objects By Parameter
Hi
I have two problems
First
I have a dictionary of objects (Sentence). I want to do a For...each, to modify all the objects in my dictionary but I want to use them by ref
dSentences: Dictionary
Sentence: Object
Display: Sub of Sentence
********************
Dim sKey As Variant
For Each sKey In dSentences
Debug.Print (sKey)
dSentences.Item(sKey).Display 'To use them directly in the dictionary
Next
********************
Results:
"key1"
"Value3"
"key2"
"Value3"
"Key3"
"Value3"
Gives only the value of the last Object of the Dictionary. I don't understand because the sKey always change
Maybe my syntax is bad, but it executes Display.
The second one: how to send objects to other subs by ref? I tried the traditional way but it don't seems to work
Thanks for your help
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?
Objects: Incorporating Arrays And Other Objects
Hi, I'm new.
I am just learning OOP and am trying to create a "camera" object. What this camera does is "takes a picture" of arrays of points and lines in 3D space and puts it on a PictureBox using Visual Basic's PSet and Line methods. I had been using this camera frequently in non-object form, but distributed in different subs, (e.g. to orient the camera, to move the camera, to change its sensitivity, etc.).
I am using the VB5 professional edition and am confused about two things:
1) Visual Basic does not allow arrays to be public members of Objects:
Option Explicit
Public Point(32000) as Point3D 'Gives Compile Error
Public Line(32000) as Line3D 'Gives Compile Error
I can work around this by using Private arrays and transferring data one at a time from the outside with a loop structure. However, this doesn't seem eloquent to me. Is there a leaner way to fix this?
2) How do I incorporate a PictureBox into an Object? Can I make a separate PictureBox within the camera object and transfer the picture to the outside PictureBox? Or can I somehow reference the outside PictureBox to the camera object?
Any suggestions, general or specific, would be greatly appreciated .
Thanks!
Reference To Objects And Clone Objects
Hi,
I have a question about object references:
I did this:
...
Dim Collection1 As New Collection
Collection1.Add "Hello"
Collection1.Add "World"
Dim Collection2 As Collection
Set Collection2 = Collection1
...
Does Collection1 and Collection2 have a reference to the same
object?
If they do, how can I clone Collection1, and make Collection2 point at it???
Thanks,
T.
[Reopened]Some Questions For Learners......[Real Dumb Questions]#Sorry#
Hi i just started learnin VB few weeks ago...
i have a couple of dumb questions to ask
1)How long did it take for you all to learn VB?<<<sry for it but just wanted to knw
2)Is it necessary to learn how to create ActiveX controls... i find it hard
3)Wat is shell programming and Win API (idk wat its knwn as )... ?
well these are terms i wanted to get info abt...
I KNW IT ALL SOUNDS DUMB! BUT ATM... IM TOO BUGGED SRY
thx in advance
Hide Sheets/objects, Save, Unhide Sheets/Objects
There was another post about this recently. I have pieced my code together with that and the help doc. here is what I got.
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim strCurrentSheet As String
strCurrentSheet = ActiveSheet.Name
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
If Hidden_Elements_Hidden = False Then Call Hidden_Elements_Hide
If SaveAsUI Then ThisWorkbook.SaveAs Application.GetSaveAsFilename Else ThisWorkbook.Save
If Hidden_Elements_Hidden = True Then Call Hidden_Elements_Show
Sheets(strCurrentSheet).Activate
'NOTE THIS LINE
Cancel = True
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Workbooks(ThisWorkbook.Name).Saved = True
End Sub
This works fine if I manually save the workbook and then manually close it.
Although, if I just goto close the following happens. I get the save changes prompt. After it saves, I get that same prompt again.
Any Ideas?
Edit:
Is there a way to test if the document is closing in the beforesave event?
Objects Inside Objects??
Hi. I am pretty new to object-oriented programming, and I am enjoying learning it with VB6, although I know it is not a proper OO language. I was wondering....
When using VBA in Excel for example, you can get a string of objects like: object.object.collection(x).anotherobject.yetanotherobject.property. E.g.
Code:
Selection.Interior.ColorIndex = 3
How can I put objects inside other objects like this in my own self-made classes? BTW, I'm not interested in Excel, I was just using it as an example of what I mean.
Regards,
John
|