right function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

To all,

I'm using the current code below and for some reason I'm not getting
anything into my variable. I'm expecting to see "efghijk". I have rebuilt
my project/solution but still to no avail. This code has worked at one point
but I can't explain why it doesnt work. Any help or suggetstions.

Dim account As String
account = "abcdefghijk"

Dim TESTing As String = Microsoft.VisualBasic.Right(account, 7)

Thanks,
Michael
 
Does it work if you write it:

Dim TESTing As String

TESTing = Microsoft.VisualBasic.Right(account, 7)
 
Michael de Vera said:
I'm using the current code below and for some reason I'm not getting
anything into my variable. I'm expecting to see "efghijk". I have rebuilt
my project/solution but still to no avail. This code has worked at one point
but I can't explain why it doesnt work. Any help or suggetstions.

Dim account As String
account = "abcdefghijk"

Dim TESTing As String = Microsoft.VisualBasic.Right(account, 7)

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
Hi Michael,

I performed a test on Microsoft.VisualBasic.Right function, but didn't
reproduce the problem. The function always returns the correct result in my
test.

Perhaps the variable 'account' has been changed before you call
Microsoft.VisualBasic.Right function.

If the problem still exists, you may show us your complete related code or
send me a sample project that could just reproduce the problem. To get my
actual email address, remove 'online' from my displayed email address.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
To all,

Below is the complete code that I'm using to build a treeview. As you will
see each node is populated by a category ....such as NA division, department,
then employee name. What I'm trying to do is to parse the node value that is
passed to my sub-routine called, "Information". The node that passes the
value to my information subroutine is from the subroutine called, "Employee",
which has a value in a comma delimeted information ....e.g. Michael de Vera,
1234. The value is passed when a user clicks on the appropriate node in my
tree view.

What I'm trying to do is to only get 1234. I can put a break in my code and
see that the node.value from the subroutine employee is actually passing the
correct value when the appropriate node is clicked for employee. I tried
several variations to figure why the right function code won't work but I'm
still unsuccessful. I have also tried using instr and mid functions but
those don't work either.

Thanks for any help.

Michael

Protected Sub tv_NA_Divisions_TreeNodePopulate(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles
tv_NA_Divisions.TreeNodePopulate
If e.Node.ChildNodes.Count = 0 Then
Select Case e.Node.Depth
Case 0
PopulateNADivision(e.Node)
Case 1
PopulateNADepartment(e.Node)
Case 2
Employee(e.Node)
Case 3
Information(e.Node)
End Select
End If
End Sub

Sub PopulateNADivision(ByVal node As TreeNode)
Dim ds As DataSet
ds = DataAccess.Division_Description()

If ds.Tables.Count > 0 Then
Dim row As DataRow
For Each row In ds.Tables(0).Rows
Dim newnode As TreeNode = New _
TreeNode(row("NA Divisions").ToString())
newnode.PopulateOnDemand = True
newnode.SelectAction = TreeNodeSelectAction.Expand
node.ChildNodes.Add(newnode)
Next
End If

End Sub

Sub PopulateNADepartment(ByVal node As TreeNode)
Dim ds As DataSet
ds = DataAccess.Department_Description(node.Value)

If ds.Tables.Count > 0 Then
Dim row As DataRow
For Each row In ds.Tables(0).Rows
Dim newnode As TreeNode = New _
TreeNode(row("NA Departments").ToString())
newnode.PopulateOnDemand = True
newnode.SelectAction = TreeNodeSelectAction.Expand
node.ChildNodes.Add(newnode)
Next
End If

End Sub

Sub Employee(ByVal node As TreeNode)
Dim ds As DataSet
ds = DataAccess.Employee_by_Department(node.Value)

If ds.Tables.Count > 0 Then
Dim row As DataRow
For Each row In ds.Tables(0).Rows
Dim newnode As TreeNode = New _
TreeNode(row("Employee Name").ToString() & "," & " " &
row("EXT").ToString())
newnode.PopulateOnDemand = True
newnode.SelectAction = TreeNodeSelectAction.Expand
node.ChildNodes.Add(newnode)
Next
End If

End Sub

Sub Information(ByVal node As TreeNode)

Dim account As String
account = "abcdefghijk"

Dim TESTing As String
TESTing = Right("abcdefghijk", 4)


'Dim GID_String As String = Microsoft.VisualBasic.Right(node.Value, 4)

End Sub

End Class
 
OK! Call me the biggest dummy! I was not setting my breakpoint past the
right function ....thus not seeing any value inside of the variable called,
account. If I were to do the following the below then everything
works.....especially if I put my breakpoint on textbox1.text.

Sorry for any confusion that I may have caused.


Dim account As String = "abcdefghijk"
Dim TESTing As String

TESTing = Microsoft.VisualBasic.Right(account, 7)
TextBox1.Text = TESTing
 
Hi Michael,

Thank you for your sample code.

Firstly, I notice that you are using the TreeNode.Value property in the
subroutines-PopulateNADepartment, Employee and Information. But I don't see
you set the Value property of the treenodes when you create them in the
PopulateNADivision, PopulateNADepartment, and Employee subroutines

Secondly, can you get the correct result ("hijk") in the variable 'TESTing'
in the Information subroutine? What's the value of the 'node.Value'
expression in the Information subroutine? You may have a try using the
SubString method of String to get the substring you want as follows. Please
try it to see if you can get the correct result.

Dim GID_String As String = node.Value.Substring(node.Value.Length - 4, 4)

Hope this helps.

BTW, I will be on a long vacation from the next Monday to Friday. During my
leave, my team mates will follow up with you and it may not in time. Sorry
for the inconvenience it may bring to you!


Sincerely,
Linda Liu
Microsoft Online Community Support
 
Hi Michael,

Since my colleague Linda is on vacation this week, I will continue to work
with you.

How about this issue now? Does Linda's reply make sense to you? If you
still need any help, please feel free to feedback, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Jeffrey,

Thanks for your response. I made an earlier post on 2/15 indicating my
issue as a mistake of my own. I wasn't putting a break past my variable to
see if it would be populated by a string that contained a right function.

This was a very rookie mistake.

Thanks,
Michael
 
Hi Michael,

Oh, thanks for your confirmation. It seems that I missed that reply in this
thread, sorry.

Anyway, if you need further help, please feel free to post, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top