|
The issue is on line 3. If the first character in the string is a '\', which it likely will be with a path such as "\\Foo\Bar", then the index will be zero causing it to skip over your If condition.
You should change it to >= 0, like this...
If myStartPointer >= 0 Then
|
|
|
|
|
That would cause a problem if the back slash was at postion 0. This error happens even when the position is in the middle of the string.
Example MYDOMAINNAME\myusername
The results is from my code \myusername
If I add one to the start position of the Mid() method I will get \yusername
The code has nothing to do with the starting position it has to do with the removal of the back slash.
Bob Zagars
Senior Software Engineer
|
|
|
|
|
Bob Zagars wrote: That would cause a problem if the back slash was at postion 0. This error happens even when the position is in the middle of the string.
Your code has 2 bugs in it then. The first one I already mentioned. The second bug is with how you're extracting the substring.
You are being confused by the Mid() function. Mid() is a function that was used in VB6 and only exists in VB.NET for compatibility reasons. Mid() expects 1 based indexes, which is the way indexing used to work in VB6. The .NET String class uses zero based indexes. This is why you are one character off.
You should call String.Substring() instead.
|
|
|
|
|
Dim myStartPointer As Integer = Me.ebLoginName.Text().IndexOf("\")<br />
Dim myLength As Integer = Me.ebLoginName.TextLength()<br />
Dim myString As String = Me.ebLoginName.Text()<br />
If myStartPointer >= 0 Then<br />
Me.ebLoginName.Text() = myString.Substring(myStartPointer + 1)<br />
Me.mccDomain.Clear()<br />
End If
Same problem can not get rid of back slash.
myStartPointer is suppose to be the indexed location of the back slash.
Input string MYDOMAINNAME\test
Results \test
Bob Zagars
Senior Software Engineer
|
|
|
|
|
Bob Zagars wrote: Dim myStartPointer As Integer = Me.ebLoginName.Text().IndexOf("\")
Dim myLength As Integer = Me.ebLoginName.TextLength()
Dim myString As String = Me.ebLoginName.Text()
If myStartPointer >= 0 Then
Me.ebLoginName.Text() = myString.Substring(myStartPointer + 1)
Me.mccDomain.Clear()
End If
I've just ran your above code with the string "MYDOMAIN\test". It worked for me. Either the input string is not what you expected or the problem lies elsewhere in your code. In either case, I recommend that you step through your code in the debugger and keep a sharp eye on your ebLoginName.Text property.
|
|
|
|
|
Joshua Quick wrote: Dim myStartPointer As Integer = Me.ebLoginName.Text().IndexOf("\")
Dim myLength As Integer = Me.ebLoginName.TextLength()
Dim myString As String = Me.ebLoginName.Text()
If myStartPointer >= 0 Then
Me.ebLoginName.Text() = myString.Substring(myStartPointer + 1)
Me.mccDomain.Clear()
End If
I've just ran your above code with the string "MYDOMAIN\test". It worked for me. Either the input string is not what you expected or the problem lies elsewhere in your code. In either case, I recommend that you step through your code in the debugger and keep a sharp eye on your ebLoginName.Text property.
Okay this tells me something because I thought I was crazy and could not understand how my results kept adding a back slash. I am using a class library from Janus Systems. It is their EditBox which has to be the problem. I will submit at their web site.
Thanks for your help.
Bob Zagars
Senior Software Engineer
|
|
|
|
|
You are dead wrong. Here is the class String Indexof() method.
"Reports the index of the first occurrence of the specified String in this instance."
....
"Return Value
The index position of value if that string is found, or -1 if it is not. If value is Empty, the return value is 0."
I have not tested at the first position which might be position 0 or 1 but my problem is not related to this issue. Mine happens in the middle of the string.
Bob Zagars
Senior Software Engineer
|
|
|
|
|
Bob Zagars wrote: You are dead wrong.
I'm not wrong. Your code does fail if a back slash is found at index 0. Try this string: "\\Foo".
|
|
|
|
|
Joshua Quick wrote: I'm not wrong. Your code does fail if a back slash is found at index 0. Try this string: "\\Foo".
I am sorry but my code will never have "\\" in it only DOMAINNAME\username which I am getting off the problem, If you do not have an answer that will solve my problem stop replying.
Bob Zagars
Senior Software Engineer
|
|
|
|
|
you can use the Replace method of the string.
newstring = strbackslash.Replace("\","")
|
|
|
|
|
Or just get the code right in the first place and forget about this little "patch".
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i was told i need to use invoke to marshal to fix this exception : Control 'TxtFolderActivity' accessed from a thread other than the thread it was created on. i cant seem to figure it out. here is the snippet of code where i need the invoke.
<br />
<br />
Private Sub logchange(ByVal source As Object, ByVal e As _<br />
System.IO.FileSystemEventArgs)<br />
<br />
<br />
If e.ChangeType = IO.WatcherChangeTypes.Changed Then<br />
TxtFolderActivity.Text &= "File " & e.FullPath & _<br />
" has been modified" & vbCrLf<br />
End If<br />
<br />
If e.ChangeType = IO.WatcherChangeTypes.Created Then<br />
TxtFolderActivity.Text &= "File " & e.FullPath & _<br />
" has been created" & vbCrLf<br />
End If<br />
If e.ChangeType = IO.WatcherChangeTypes.Deleted Then<br />
TxtFolderActivity.Text &= "File " & e.FullPath & _<br />
" has been deleted" & vbCrLf<br />
<br />
End If<br />
<br />
End Sub<br />
Makniteasy
|
|
|
|
|
You're not allowed to interact with a Form on a separate thread.
What you need to do is call BeginInvoke(). What this will do is push a delegate to the end of the Windows message queue. That delegate will be invoked on the UI thread, which will allow you to safely write your string to the TextBox.
The following article has more information. See the code example at the bottom.
http://www.codeproject.com/csharp/begininvoke.asp[^]
|
|
|
|
|
If I have a web form, and a button. How do I work it that when that button is pressed it will redirect the user to another webform. And on that new webform there will be a standard label, and the labels text will change to a value specified in the button on the first web form.
Does that make sense? Hope it does, any help appreciated.
|
|
|
|
|
Hi
to move from one page to another (redirect) use this code
server.transfer("Your Path or the form name you want to go to")
ex: server.transfer("WebForm2.aspx")
to make the label on the second page change and to pass a certain value to it you can do that in different ways:
1. to set a cookie value and retreive it on the form
2. to pass the value as a URL variable to the new form
3. to set a session and retreive its value on the new form
I hope that i have helped you!
Best wishes
Regards
Mohammad Rabay'a
|
|
|
|
|
Dear all
I am wondering that in VB is there a way to compare the system time and the schedule time stored in MS Access database??
Thanks alot. Hope to hear from u soon cos i m in urgent
Peter
|
|
|
|
|
Schedule time? Is this a DateTime column in your database?
And are you doing this in VB.NET?
If so, then what you'll need to do is read this from your database via ADO.NET. Since this is an MS Access database, you should use ADO.NET's OleDB provider.
You can get the current system time via "Date.Now". Here's a quick example how to compare DateTime objects.
Dim myTime As New Date(2000, 1, 31) ' Create DateTime set to Jan 1st, 2000.
If (Date.Compare(Date.Now, myTime) > 0) Then 'Compare against current time.
' Current time is greater than "myTime".
End If
|
|
|
|
|
Hi
there is a command used in .net to know the system time
this command is Now() function
if you compare it with the time retreived from the DB then I think you have the answer
I hope that I have provided the needed help
best wishes
Regards
Mohammad Rabay'a
|
|
|
|
|
Hi Mrabaya
Can u explain me abit more details? Cos i really dumb at programming.
Thanks and regard
Nyan Lin
|
|
|
|
|
How do input a multi-table DataSet to a Web Forms DataGrid
that can be inserted, updated, and deleted?
Visual Studio 2003, SqlServer DataBase
I am trying to create a datagrid that will have
fields from 4 separate tables.
When I drag in a SqlDataAdapter and
add all four tables to my query I get the following
Messages:
Generate insert statement
The original query has a select list that has
columns from multiple tables. The statement
cannot be generated automatically
for this type of query.
Generate Update statement
The original query has a select list that has
columns from multiple tables. The statement
cannot be generated automatically
for this type of query.
Generate Delete statement
The original query has a select list that has
columns from multiple tables. The statement
cannot be generated automatically
for this type of query.
|
|
|
|
|
Hi, how to copy an entire row from a dataGrid to a lisBox
a tuturial whould do fine. Thank you Andy38
|
|
|
|
|
Could someone help and redirect me or tell me what's the name of the methed that used with the screen server actions....
the examples i found sucks... i can't found the perfect exampl to help me out.
most of the examples solve the problem in one side and in a weak way and not understandable....
i and i've low resources>>>>!
Militiaware
Faris Madi
|
|
|
|
|
militiaware wrote: Could someone help and redirect me or tell me what's the name of the methed that used with the screen server actions....
What actions?
militiaware wrote: most of the examples solve the problem in one side and in a weak way and not understandable
What problem?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Anyone can give a link of the advantages using VB.net compare to classic VB ?
Thanks before...
|
|
|
|
|