הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Thursday, January 12, 2012 1:33 PM
Following code properly populates "wksSheetNames" Dictionary
Dim wksSheetNames As New Dictionary(Of String, String)
For Each Wks In xlsWB.Worksheets
Wks.Activate()
wksSheetNames.Add(xlsApp.ActiveSheet.codename, xlsApp.ActiveSheet.name)
Next
For example assume the code logic is correct (I know that the syntax is not correct!)
If wksSheetNames.(Key="Sheet2", Value="Inventory") then Stop
What is the correct VB.Net syntax to "Stop" in the above line?
Thanks in advance!
Dennis
All replies (6)
Thursday, January 12, 2012 1:49 PM ✅Answered | 2 votes
By using the Item() property with key as parameter you will get the value as return.
See if this helps you:
'Visual Basic 2008 - .net 3.5 - Any CPU
Dim x As New Dictionary(Of String, String)
x.Add("1", "one")
x.Add("2", "two")
x.Add("3", "three")
MsgBox("Value of 2:" & x.Item("2"))
Hannes
If you have got questions about this, just ask.
In a perfect world,
users would never enter data in the wrong form,
files they choose to open would always exist
and code would never have bugs.
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
Thursday, January 12, 2012 1:42 PM
Dennis,
what do you mean by STOP ? Stopping the execution of the programm, stopping the iteration of the loop ? Please rephrase what you want to achieve.
Hannes
If you have got questions about this, just ask.
In a perfect world,
users would never enter data in the wrong form,
files they choose to open would always exist
and code would never have bugs.
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
Thursday, January 12, 2012 1:47 PM
In the example I used, to keep it simple, I stated for the code processing to Stop.
That said, it was only an example.
What I need is the correct syntax to Search the Dictionary "wksSheetNames" ane Return the related "Value" for a Searched Key.
Thursday, January 12, 2012 2:04 PM
Thanks!
I figured that it had to be simple and reading page after page of "Dictionary" web pages I made no progress in over an hour.
Take the gold ring!
Thursday, January 12, 2012 2:09 PM
Take the gold ring!
No, just send me the cash ;-)Hannes
If you have got questions about this, just ask.
In a perfect world,
users would never enter data in the wrong form,
files they choose to open would always exist
and code would never have bugs.
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
Thursday, January 12, 2012 8:45 PM
Cash is King