|
I want to drag Image and Image will follow cursor until we drop it.
Such as we drop it in Panel Area
(Like when you drag "Textbox" Control and Place to Designing Form in Visual Studio)
I do it and have problem with Mouse Position
I don't find Cursor Location when I over Panel Area
I use VB.NET 2005
|
|
|
|
|
The easiest way to do this is to draw the image yourself on the screen, no picture box. If you want to do drag and drop, impliment it as drag n drop ( that is, use the messages provided by the framework ), and set the cursor of the controls you can drag over, including the main window, to be one you create of the image in question.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hi i placed 2 richtextboxes and one button on a form
1st richtextbox named "result"
2nd richtextbox named "text1"
i want when i click on button,then it search the word "abcd" in text1.text, if found then write result.text in text1.text in second line("abcd" may be in any line)
so i coded on button :
If InStr(Text1.Text, "abcd") Then
text1.Text = text1.Text + InStr(text1.Text, "abcd") & Microsoft.VisualBasic.ChrW(13) + result.Text
End If
but it gives error that
An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll
Additional information: Cast from string "abcd" to type 'Double' is not valid.
|
|
|
|
|
Are you sure that the error message comes from the code that you have shown? The only thing that seems relevant in the error message is the string "abcd", unless of course if you created your own InStr function.
---
b { font-weight: normal; }
|
|
|
|
|
|
I see. Yes, perhaps your strange code might produce that error, but I am not really sure how. Perhaps the compiler got confused by all your implicit conversions, and tried to convert everything to the number with the largest capacity, which is a double.
If you use a bit less implicit conversions, I'm quite sure that it might work better. The InStr function returns an integer, not a boolean and not a string. If you want to concatenate strings, either stick to the & operator, or make sure that what you are concatenating is really strings.
---
b { font-weight: normal; }
|
|
|
|
|
ok so can you tell the codes which will work?
|
|
|
|
|
I just explained some problems with your code. Can't you at least make an attempt to fix them before asking me to do the work for you?
---
b { font-weight: normal; }
|
|
|
|
|
man i tried about 50 times and every angle but no benfite then i wrote my problem in this forum
|
|
|
|
|
The "+" signs cannot be used to concatenate strings together. You MUST use "&" signs. Also Instr is deprecated. I think it's replacement is String.IndexOf[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: The "+" signs cannot be used to concatenate strings together. You MUST use "&" signs.
That is not true at all. The + operator can be used to concatenate strings just fine. The & operator is used when you concatenate values that doesn't need to be strings, but you want them to be converted to strings first.
Dave Kreskowiak wrote: Also Instr is deprecated. I think it's replacement is String.IndexOf[^].
Not really deprecated. It's one of the functions in the Microsoft.VisualBasic assembly for simplifying the transition from VB 6.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: That is not true at all.
True, but that's what happening in this case. I'm telling him that to keep him locked into putting string together with one operator (&) and doing math with the other. What's happening in his code is that the cast is failing because the value of Text1 or Result, appearing to be "abcd", is failing a conversion to Double so it can be added to the result of InStr which returns a number.
Guffa wrote: Not really deprecated. It's one of the functions in the Microsoft.VisualBasic assembly for simplifying the transition from VB 6.
I hate that we even have to do this!!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: I'm telling him that to keep him locked into putting string together with one operator (&) and doing math with the other.
So you tell a lie to make him write code in a certain way? Don't you think that the truth might have the same effect?
Or do you think that you need to be an MVP to handle the truth? For beginners it's the blue pill?
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: So you tell a lie to make him write code in a certain way?
My mistake. But, I don't see it as more than a "little white lie" though.
If putting down rules like that helps them learn the language and keep their code a little more maintainable until they learn those little idiosynchrocies, I'm all for it!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
oh man(Dave Kreskowiak) its working when i change "+" to "&" but when
i wrote "1234" in result.text and "abcd" in text1.text
and when i click on button then this appeared in text1.text:
abcd1
1234
and when i click again then this appeared:
abcd1
12341
1234
i want to know that from where the "1" coming?
|
|
|
|
|
Look at what your stringing together to get this:
text1.Text = text1.Text & InStr(text1.Text, "abcd") & Microsoft.VisualBasic.ChrW(13) & result.Text
First first part:
Text1 = The text in Text1 & Instr(blah,blah) & ...
This say take the existing text in Text1 and append the value returned by InStr, which returns a number 0-n. This is what's giving you the abcd1 and returning an ever longer string in Text1.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
so man can you tell the right code for it?
|
|
|
|
|
For what? I have no idea what you want it to do!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
ok end this topic , i will solve it
|
|
|
|
|
I work by VB.6 and I want to make a project that project should know the DIR of The windos and The DIR of the System32 file outomaticaly . How can I do that? Is there a code I can Use it to get the windows DIR and the system32 file DIR or not?????????????
Thank You For Help
soly
|
|
|
|
|
You're looking for the FileSystemObject[^] and it's Files collection.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I would like to retrieve records from a dataset and read the values as when performing an SQL statement on a database.
Datatable is created programmtically with the following columns:
...
With dtPlateauPositions
.Columns.Add("xPosition", System.Type.GetType("System.Int32"))
.Columns.Add("yPosition", System.Type.GetType("System.Int32"))
.Columns.Add("occupied", System.Type.GetType("System.Boolean"))
End With
...
I have tried filtering using the .select method of the datatable, however, it is not returning a subset (problem 1).
Public Function isOccupied(ByVal x As Integer, ByVal y As Integer) As Boolean
Dim rowToSearch As DataRow
Dim strExpr As String
Dim strSort As String
strExpr = "xPosition =" & x
strSort = ""
' Use the Select method to find all rows matching the filter.
Dim foundRows As DataRow() = dtPlateauPositions.Select(strExpr, strSort, DataViewRowState.Added)
foundRows = dtPlateauPositions.Select()
For example I want to retrieve (in SQL) Select occupied from dtPlateauPositions where xPosition = myX and yPosition = myY. Hence, how do I filter expressions with criteria on multiple columns?
Jon
-- modified at 14:23 Saturday 30th September, 2006
|
|
|
|
|
<br />
datatable.Select("xPosition="& myX & " and yPosition="& myY)<br />
add as many columns....
|
|
|
|
|
i made an application in which i made two forms
form1 have one textbox and one button,
form2 have only one button
i want when i click on form1`s button then form2 should show and when form2`s button pressed then
form1`s textbox.text should be any number(ex. 1111)
for show form2 i wrote code in form1`s button:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim f As New Form2
f.Show()
End Sub
ITS WORKING
for changing form1`s textbox.text i wrote in form2`s button:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As New Form1
a.TextBox1.Text = "111"
End Sub
NOT WORKING
someone know what the cause of its not working?
|
|
|
|
|
xmen_xwk wrote: Dim a As New Form1
a.TextBox1.Text = "111"
I'm at a loss as to why so many people do this. a is a NEW instance of Form1. It has nothing whatsoever to do with the instance of Form1 that already exists and is visible. a has the text 111, and the other instance keeps whatever text it had.
You need to set up a delegate between Form1 and Form2, so that Form2 can call a method in Form1 and pass through the value.
Also, you need to keep your controls private or protected. I guess you've come from VB6 ? VB.NET is an object oriented language, one of the things you should aim to achive in an OO language is to hide as many details of your class to clients as possible.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|