|
|
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
|
|
|
|
|
man i m new in vb.net so please tell the codes
i dont know what is delegate ??
yeah you guessed right, i used vb 6 it was so easy
|
|
|
|
|
The problem is it's too easy on vb6.
Another way to do it is form2 return some values and a flag to indicate whether the values from forms 2 is valid, to whichever form that call form2.
Form2
Has public property of ReturnValue, which set some value depending on user action (drop down selected index changed, text box etc)
Has boolean flag IsValid to indicate the ReturnValue is valid (in case user didn't select anything, yada, yada)
On Form2 OK button, set DialogResult to DialogResult.OK
Validate return value, if validate OK, set IsValid to true else false.
Close Form2.
On Form1 button event
new Form2 and Show(), and save Form2 DialogResult
check Form2 DialogResult, if it is DialogResult.OK, check IsValid, if IsValid is true, take value from ReturnValue and put in Form1.TextBox.Text.
Passing Values Between Forms
|
|
|
|
|
hi i did it , to do code
1st i made a module and coded it:
Module Module1
Public t As Integer
End Module
then i wrote code in form2`s button:
t = 22
Me.Hide()
and then i wrote code in form1`s activated:
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
TextBox1.Text = t
End Sub
now its working
|
|
|
|
|
OK - you're still using VB6 ? This will work, but, as I said, it's really a bad way to go about things. If you're doing hobby stuff, it probably doesn't matter, but I'd be speaking to anyone on my team who wrote code like this.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|