View Full Version : Visual Basic Help Needed!
hey everyone! i'm running into a dilemna. I have a Visual Basic 6 project due on monday and in this project I have to take an image and make it move from the top left corner of the screen to the bottom right and it has to move diagonally, it cant move across and then down.
I have tried all kinds of coding, but cant seem to make it move diagonally. If anyone can give me the coding to do so I would greatly, greatly appreciate it.
Thx
You should have two Properties for the picture box TOP and LEFT you need to put these in a Loop
For loop = 1 to 100
picturebox1.left + 1
picturebox1.top +1
next loop
this should work
I'm not sure about the + 1 it might need to be -1 I don't have VB installed any more the size of the loop you will just have to play with or place the Picture box at the Bottom right where you want it to stop and write down the Left and top values and use a do wile loop.
Tryn
thanks for the help tryn :)
Your welcome
let me know if it worked or if you have any other question I had a class on VB6 in college but we did not get into very advance stuff but it was fun.
I installed VB here is the Code i used and it worked
My form was 7065 wide and 5610 Hight
While Picture1.Top < 4320 And Picture1.Left < 5640
Picture1.Top = Picture1.Top + 1
Form1.Refresh
Picture1.Left = Picture1.Left + 1
Wend
You may have to play abound with the Form width and other values to get it to work.
Tryn
thanks for that new information man. i am going to take you up on your offer for help. let me break down my latest scenario.
i have created a spreadsheet that will list amount of desks sold and their price. the text box where the amount of desks are entered is called txtItem and the text box for the price is called txtPrice. I then have to multiple the item by the price and put in the total field. once that is done a 10% discount has to be added to the total. i have done the coding to reflect the item and the price in the total field, but i cant figure out how to do the coding for the discount. I will enter below what I have exactly in the Calculate Button Event Procedure.
Dim strItem as String,strState as String
DIm sngPrice as Single, sngDisc as Single
Dim CurSales as Currency
'assign values to variables
strItem = txtItem.Text
strState = txtState.Text
sngPrice = Val(txtPrice.Text)
sngDisc = Val(lblDisc.Caption)
curSales = Val(txtSales.Text)
'calculate order
txtSales = Val(txtItem.Text) * Val(txtPrice.Text)
cmdPrint.SetFocus
Anyway, that is the coding I have. To make it easier let me write out the exact instructions to the project to see if you can help. I have been trying to figure this one out for about a week. Hope you don't mind how far in i have taken this.
Question :
Assume you want to calculate a 10% discount on desks sold to customers in Colorado. Use the variables strItem.strState and curSales. Format the discount to standard and display it in the lblDisc control. (you don't know the case of either the strItem or the strState variables). In other words, the content of the variable can be in uppercase, lowercase or a combination of uppercase and lowercase letters. Write the pseudocode, then write the visual basic code. use the If...Then...Else Selection Structure.
anyway, thats it for this question man. Hope this is something you or someone else knows. Man i suck at programming :(
This Code Should Get it to Display the Discount Price
Dim strItem As String, strState As String
Dim sngPrice As Single, sngDisc As Single
Dim CurSales As Currency
Private Sub cmdPrint_Click()
strItem = txtItem.Text
strState = txtState.Text
sngPrice = Val(txtPrice.Text)
sngDisc = Val(lblDisc.Caption)
CurSales = Val(txtSales.Text)
txtSales = Val(txtItem.Text) * Val(txtPrice.Text)
//this Code will calulate and Display the discount
sngDisc = txtSales * 0.9
lblDisc.Caption = sngDisc
// end of code
End Sub
Also the Problem of Not Knowing what case that the stuff will be entered in as can be solved my using the Ucase(text1.text) or Lcase(text1.text) these functions automatically converts the String or text box to UPPER or LOWER case .
Hope this will help if this does not do what you need let me know
My Email is in my Profile Just Put something like Roody form SG in the subject so I will see it Or PM me
tryn
thanks for the info Tryn. I will add that code here shortly and let you know how it goes. Thanks :)
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.