|
Hi,
I have create on button in Flash.
When i click that button. It will invoke one of my forms or let's say bring me to form2.vb .
Can any one guide me how to do this?
Thanks in advance.
|
|
|
|
|
Last I checked, you can't. The button clicks in the Flash "document" do not propagate up to your form. VB.NET will never know the user clicked the button.
|
|
|
|
|
I have a simple windows form with a textbox and a button. Click the button and you get a msgbox that I am using for a hyperlink. The results are how I need them to look but I can not copy it to paste into a browser. In a perfect world, I would like to have the click generate a link instead of a msgbox but I'm such a beginner I dont expect to be able to do this easily. Any help would be appreciated! Here is the click event for the button:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("http://webmail.sale.com/loansales/search.aspx?searchcommand={LF:Name=""*" & TextBox1.Text & "*"",%20Type=""F""}")
End Sub
Is there a property that can be set on a msgbox that allows the text to be copied?
|
|
|
|
|
You can always place the information in the clipboard where the user can ctrlV it into the browser.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
if you mean just to ctrl+c, that doesnt work because it gets more than just the msgbox, it gets the title and everything else. IF there is a way to copy the results straight to the clipboard, that would work, I just dont really know how.
|
|
|
|
|
Hi,
you can programatically store the string on the clipboard using Clipboard.SetText; however that is not considered good practice, the user is in charge of the clipboard, so normally a CTRL/C should preceed any change on the clipboard.
Assuming you have a Form, you could use a Label, set the string to its Text; after that it can be copied by selecting and typing CTRL/C.
|
|
|
|
|
I know how to set the string to its text, but I also need to add dynamic text to the string that an end user will type into a text box, so what I am actually after, is to end up with a string that would look like:
http://www.website.main & (enter whatever the end user needs here) & search.com. In other words, I have the beginning of the link, and the end of the link, but the end user will be providing the middle part of the URL.
I'm way new to this, so any and all of the suggestions have been a great help and a great learning tool. Thanks
|
|
|
|
|
What about not using a message box, and simply creating your own modal/popup form that is the size and shape of a message box, hence allowing you to use a textbox to display the text to allow the user to select it, or even a button that says "copy link" or whatever... ???
|
|
|
|
|
Thats a good answer, thanks! Now all I have to do is learn how to do it.
|
|
|
|
|
I'm writing a solitaire game and trying to drag and drop card images from an array of images to on top of another array of images on a form. I'm stuck on trying to get the images dropped and MsgBoxes to work...I have them for test purposes. Here is some of my code. Note: I tried to use .net, but since I'm such a newbie, I thought I'd stay with VB6 for this. Not a school assignment. A birthday present to someone. sorry for bad format; just testing right now.
Private Sub Hearts_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
Dim HeartsIndex As Integer
Dim NewIndex As Integer
Dim Button As Integer
HeartsIndex = 0
Index = 0
For HeartsIndex = 1 To 12 - 1
For Index = 1 To 12 - 1
Hearts(HeartsIndex).Picture = Image1(Index).Picture
If Button = vbLeftButton Then
If TypeOf Source Is Image Then
Hearts(HeartsIndex).Picture = Source.Picture
End If
End If
Next
Next
NewIndex = 0
For NewIndex = 0 To 12 - 1
If Hearts(NewIndex).Picture <> Image1(NewIndex).Picture Then
Image1(NewIndex).Drag vbCancel
MsgBox ("This card does not belong here")
Exit Sub
Else
Image1(Index).Drag vbEndDrag
MsgBox ("You're right!")
Exit Sub
End If
Next
End Sub
|
|
|
|
|
Yep 4 hours later and still no response - get the hint, VB6 is dead and no longer supported, the people who usually answer forum questions are all using .net and have been for years, any help from them will be based on them dragging old info out of the deep past and is of little interest to them!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Some comments on the code.
1 The For NewIndex = 0 To 12 - 1 loop will only be done with NewIndex = 0. It must take either the If or Else branch, both of which exit the sub.
2 Why have 12-1 as end value for loops? Why not just 11?
3 In the For NewIndex = 0 To 12 - 1 Else branch you have Image1(Index).Drag vbEndDrag . Should this be Image1(NewIndex).Drag vbEndDrag ?
4 You don't need to initialise the index variables to 0 since they are set by the For statements.
5 Why is Index a parameter? Whatever value is sent in is ignored since you use it to control the inner loop. So it gets set to 1 and ends up at 12 irrespective of what was supplied. So when the sub returns, whatever variable was supplied will have value 12 (IIRC VB6 defaults to pass ByRef so it changes values in calling code). Is this what you want to do?
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Thank you David for your suggestions and expertise. You are really thoughtful, even if I'm using VB6. I tried to use .NET, but it actually takes much more expertise and code than I have, at this time...I'm learning it though....so that is why I'm using VB6 for this.
Anyhow, Index was used as a parameter because that is what I saw in several tutorials on drag/drop operations. I see your point though. I'll try again and see what I come up with. Thanks again!
|
|
|
|
|
|
|
I did some work on this, but what happens at run time is:
The message displayed is "This card does not belong here" irregardless of whatever image1 card I place drag and drop over the hearts card. I can drag the matching card, or another one to the very same slot and that message is displayed. It's like the code never gets past the <> line.
At run time, after I drop the image1 card over the hearts card, then all the cards in the image1(0) slot automatically drop on the same position hearts cards. Any ideas on how I can wrestle with this would be appreciated.
Private Sub Hearts_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
Dim HeartsIndex As Integer
Dim NewIndex As Integer
Dim Button As Integer
For HeartsIndex = 0 To 12
For Index = 0 To 12
Hearts(HeartsIndex).Picture = Image1(Index).Picture
If Button = vbLeftButton Then
If TypeOf Source Is Image Then
Hearts(HeartsIndex).Picture = Source.Picture
End If
End If
Next
Next
For NewIndex = 0 To 12
If Source.Picture <> Image1(NewIndex).Picture Then
Image1(NewIndex).Drag vbCancel
MsgBox ("This card does not belong here")
Exit Sub
Else
Image1(NewIndex).Drag vbEndDrag
MsgBox ("You're right!")
Exit Sub
End If
Next
|
|
|
|
|
Not sure what is supposed to be happening here so it's difficult to advise what to do. It depends on what the screen looks like e.g. what is the Hearts control, what is the Source control?
However, one obvious point is that If Button = vbLeftButton Then will never be true. And I don't think you need it. The DragDrop event is triggered when the source object is released over the target (i.e. the Hearts control). You have no way of knowing which mouse button is involved.
Another thought is that you might want to move the Source (assuming it can be dropped on target i.e. is a heart) rather than setting Hearts(x).Picture = Source.Picture.
I just fired up my old VB6 box to check help on drag-and-drop. Not exactly clear is it?
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Thanks David! I tried again but I'm thinking I'm getting more confused though....
I read through a tutorial that the target card, the one that's supposed to be dropped on, is the source card, thus I set the hearts to the source card, just like they coded.
Then image1 array of cards is supposed to equal the hearts array...if the card that is used to drop, image1, once chosen, does not equal the exact heart card to be dropped on, then the message would be "Your card does not belong here." Else, it does belong there.
I hope I'm not being even more confused when writing this, but here is what I've tried. What is happening at run time is like I find the ace card, image1(12) and try to drop it on hearts(12), it says "Your card does not belong here" then all the #12 position card in the location of the 12th card on the image1 card side, all take the spaces of hearts(1 through 12). It's weird. If you send me your email addy, I can send you a screen shot. Pardon the formatting.
Here's what I have....
Private Sub Hearts_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
Dim HeartsIndex As Integer
Dim NewIndex As Integer
For HeartsIndex = 0 To 12
For Index = 0 To 12
If TypeOf Source Is Image Then
Hearts(HeartsIndex).Picture = Source.Picture
Hearts(HeartsIndex).Picture = Image1(Index).Picture
End If
Next
Next
For NewIndex = 0 To 12
If Image1(NewIndex).Picture <> Hearts(NewIndex).Picture Then
Image1(NewIndex).Drag vbCancel
MsgBox ("This card does not belong here")
Exit Sub
Else
Image1(NewIndex).Drag vbEndDrag
MsgBox ("You're right!")
Exit Sub
End If
Next
End Sub
|
|
|
|
|
Sounds a bit of a strange tutorial, how can source and target be the same?
As I said I'm not sure what the GUI is like so here's my take on what you might need to do.
Assuming you have four piles (one each for Hearts, Spades, Clubs and Diamonds) each being a control array of images. The aim being to complete each pile by placing cards on it in order.
You also have a deck of cards and possibly one or more heaps of cards (it depends on the version of solitaire you want to play).
Simplifying, the rules are that the top card of the deck is turned face up. It can then be placed on one of the piles or one of the heaps. A card can be moved from a heap to the appropriate pile provided it is same suit and 1 higher in value than top of pile (if the pile is empty it must be the Ace).
In terms of code the source will be the selected card on a heap, or the top of deck; the target will be one of the piles.
So the piles must react to the DragDrop event (as in your Hearts_DragDrop).
The question is what must it do in this event? The answer depends on the rules of the game and your GUI design. However, it should only be dropping one card onto the top of the pile. Your first loops are trying to drop all the image1().Pictures onto all the Hearts().Pictures. Looking at the code it has the same effect as this bit of code (not what I think was intended):
For HeartsIndex = 0 To 12
If TypeOf Source Is Image Then
Hearts(HeartsIndex).Picture = Image1(12).Picture
End If
Next
I.e. the effect is to set all the Hearts().Pictures to image1(12).Picture.
It might be better to continue this off-forum, if so, you can mail me as riced with domain david-rice dot demon dot co dot uk . (obviously in proper email address format!)
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Hi,
I've been working more on this and came up with the following. wondering if State variable makes any difference. Anyhow, when I run at runtime, the card from image1 pile that I drag from the left to the right over the same card, actually copies all of those cards in the entire suit of the hearts cards. Hope this makes sense. Here is the code.
Private Sub Image1_DragOver(Index As Integer, Source As Control, _
X As Single, Y As Single, State As Integer)
Dim HeartsIndex As Integer
For Index = 0 To 12
For HeartsIndex = 0 To 12
If State = 0 Then
Hearts(HeartsIndex).Picture = Image1(Index).Picture
End If
Next
Next
End Sub
Private Sub Hearts_DragOver(Index As Integer, Source As Control, _
X As Single, Y As Single, State As Integer)
Dim HeartsIndex As Integer
If State = 2 Then
If Hearts(HeartsIndex).Picture <> Image1(Index).Picture Then
Image1(Index).Drag vbEndDrag
MsgBox ("You're Right")
Exit Sub
Else
Image1(Index).Drag vbCancel
MsgBox ("You're Wrong")
End If
End If
End Sub
Private Sub Image1_DragDrop(Index As Integer, Source As Control, _
X As Single, Y As Single)
If Source.Name <> Image1(Index).Picture Then Exit Sub
Image1(Index).Picture = Source.Picture
End Sub
Private Sub Hearts_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
For Index = 0 To 12
Hearts(Index).Picture = Source.Picture
Next
End Sub
|
|
|
|
|
I don't think you want to be doing this.
When you drag a card from the left (i.e. image1(x)) to right, when the dragged card enters the Hearts() area then Hearts_DragOver is triggered. At this point you should only be doing something like changing the Hearts background to give visual indication to the user; and restoring original background if state = 1. You should not be changing the image to that of the card you have dragged - that should be done in Hearts_DragDrop.
The state variable only tells you if you are entering (0), leaving (1) or moving within (2) the target area. So when state=0 and the user releases the mouse button, a Hearts_DragDrop event is triggered - it's in that event that you would want to change the image.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Thank you; so this code wouldn't work then? I thought I had it close, but get a runtime error of 340. So, I'll take heed of your suggestion though; back to the drawing board. Thanks in advance.
Private Sub Hearts_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
Dim NewIndex As Integer
'For Index = 0 To 12
'If TypeOf Source Is Image Then
' Hearts(Index).Picture = Source.Picture
'End If
'Next
Index = 0
NewIndex = 0
For Index = 0 To 12
For NewIndex = 0 To 12
Image1(Index).Picture = Hearts(NewIndex).Picture
Index = Index + 1
NewIndex = NewIndex + 1
Next
Next
For Index = 0 To 12
For NewIndex = 0 To 12
If Image1(Index).Picture = Hearts(NewIndex).Picture Then
Image1(Index).Drag vbEndDrag
MsgBox ("You're right!")
Exit Sub
Else
Image1(Index).Drag vbCancel
MsgBox ("This card does not belong here")
Exit Sub
End If
Next
Next
End Sub
|
|
|
|
|
I'm a bit still confused; you think I should use dragover? dragdrop seems to allow me to drag and drop the cards just fine. Problem is I don't know how to write the code for this....what you are stating....I know State is for dragover, but if I don't use that, I use source for dragdrop. Now I don't even know the right settings for the cards on the left and on the right for in design mode, dragmode, oledragdrop, and oledrag...something, can't remember off the top of my head. But now I have all those confused and that's what might be causing my code not to work properly. Can you pleeeeeese help? You're my only hope.
|
|
|
|
|
ymilan wrote: you think I should use dragover?
Not for dropping the image. As I said you should only be changing something like the background or border of the target to give user feedback. If you don't want to give feedback do nothing.
To see why imagine you have a form with four images.
On the left is an image called theShape; on the right are three images called BoxA, BoxB and BoxC.
Imagine that the user selects theShape image and drags it to the right of the form (i.e.they are holding the mouse button down).
Suppose they drag the shape over the BoxA image. This will trigger the BoxA_DragOver event with state = 0. What should this event do? One option is nothing, so you don't write any code for the event. Another option is to change the border or color of the BoxA image so the user knows that theShape is over BoxA. What you should not do is set BoxA image to theShape image. The user has not released the mouse button so they don't want theShape to be in BoxA.
If the user does release the mouse button then the BoxA_DragDrop event is triggered. That is when you might want to set BoxA image to theShape so that the code to do so should be in the BoxA_DragDrop event.
Suppose the user drags theShape over the BoxA image (without releasing the mouse button) and then drags it over the BoxB image. Two things happen. First the BoxA_DragOver event is triggered with state = 1; then the BoxB_DragOver event is triggered with state = 0. In this case the BoxA_DragDrop could set the border or color back to their original values and the BoxB_DragDrop could change the border or color of BoxB image. Again, BoxB_DragOver should not set the BoxB image to theShape image. The user might continue the drag so it goes over BoxC.
If you imagine that the images for the boxes are much larger than theShape image, then as the user drags theShape around in a box image the DragOver event is triggered continuously with state = 2. In most cases that does not matter so the code does nothing.
This all means that the typical code for a DragOver event will be something like:
If State = 0 Then
'Do something like change border or color of the box
'You simply want to make user aware of where theShape has been dragged too
Else
If State = 1 Then
'Set the border/color of the box back to original value
Else 'State = 2
'Do nothing - they are moving around within the box
End If
End If
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Awesome! I understand dragover now! I will write that and see how I do. However, please assist on dragdrop; what do I put in that code? I tried hearts(index).Picture = Source, like every tutorial I read said to do. Then do I do vbenddrag and vbcancel like I did before, or is this in error?
|
|
|
|
|