Click here to Skip to main content
15,888,610 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questiondifference between these code Pin
yuifox13-Sep-12 23:39
yuifox13-Sep-12 23:39 
AnswerRe: difference between these code PinPopular
Dave Kreskowiak14-Sep-12 4:09
mveDave Kreskowiak14-Sep-12 4:09 
GeneralRe: difference between these code Pin
yuifox14-Sep-12 12:44
yuifox14-Sep-12 12:44 
AnswerRe: difference between these code Pin
Pravin Patil, Mumbai14-Sep-12 5:17
Pravin Patil, Mumbai14-Sep-12 5:17 
GeneralRe: difference between these code Pin
yuifox14-Sep-12 12:50
yuifox14-Sep-12 12:50 
GeneralRe: difference between these code Pin
Pravin Patil, Mumbai14-Sep-12 23:39
Pravin Patil, Mumbai14-Sep-12 23:39 
AnswerRe: difference between these code Pin
SoyDesarrollador.net12-Oct-12 8:50
SoyDesarrollador.net12-Oct-12 8:50 
QuestionXML parsing function returns 0 instead of stored value Pin
iyl7813-Sep-12 15:17
iyl7813-Sep-12 15:17 
I'm having a problem I can't seem to find the source of in a program I'm developing. The following function parses an XML file to find the names of registry keys and associated values that are linked to the selection of a drop-down box in the UI. The function retrieves keys with no problem. when asking for the values, it always returns 0, and I can't seem to figure out why. Thanks for taking a look and any suggestions/solutions you may come up with.

I've included the source of the function below and a sample of the XML -
VB
Public Function GetCfgOption(ByVal strSetting As String, ByVal intSelectedIndex As Integer, ByVal strDataType As String, Optional ByVal intOptIndex As Integer = 0) As String

    Dim xmlSettings As New Xml.XmlDocument
    xmlSettings.Load("SrcBench.xml")

    Dim nodeSetting As Xml.XmlNode
    nodeSetting = xmlSettings.SelectSingleNode("/CONTENT/Settings/" & strSetting & "[Index='" & intSelectedIndex & "']")

    Dim nodeOption As Xml.XmlNode
    nodeOption = nodeSetting.SelectSingleNode("/CONTENT/Settings/" & strSetting & "/Setting[@Index='" & intOptIndex & "']")

    Select Case strDataType
        Case "Key"
            Return nodeOption.ChildNodes.Item(0).InnerText
        Case "Value"
            Return nodeOption.ChildNodes.Item(1).InnerText
    End Select

    Return Nothing
End Function

This function would be called like so:
VB
GetCfgOption("FilterMode", intFilterModeIndex, "Key"<, 0>) 'intFilterModeIndex would be a variable and can = 0-5; the ", 0" at the end is assumed
GetCfgOption("FilterMode", intFilterModeIndex, "Value"<, 0>)
GetCfgOption("FilterMode", intFilterModeIndex, "Key", 1) 'explicitly including 1 would get the 2nd set of key/value, 2 the 3rd, and so on
GetCfgOption("FilterMode", intFilterModeIndex, "Value", 1)

This could be tested using a Console.WriteLine() statement. Calling the function with "Value" always returns "0".

The following is a section of the XML file being accessed:
XML
<?xml version="1.0" encoding="UTF-8"?>
<CONTENT>

<Settings>
  <FilterMode>
    <Index>0</Index>
    <Option>Bilinear</Option>
    <Setting Index="0">
      <Key>mat_forceaniso</Key>
      <Value>0</Value>
    </Setting>
    <Setting Index="1">
      <Key>mat_trilinear</Key>
      <Value>0</Value>
    </Setting>
  </FilterMode>
  <FilterMode>
    <Index>1</Index>
    <Option>Trilinear</Option>
    <Setting Index="0">
      <Key>mat_forceaniso</Key>
      <Value>1</Value>
    </Setting>
    <Setting Index="1">
      <Key>mat_trilinear</Key>
      <Value>1</Value>
    </Setting>
  </FilterMode>
  <FilterMode>
    <Index>2</Index>
    <Option>2x Anisotropic</Option>
    <Setting Index="0">
      <Key>mat_forceaniso</Key>
      <Value>2</Value>
    </Setting>
    <Setting Index="1">
      <Key>mat_trilinear</Key>
      <Value>0</Value>
    </Setting>
  </FilterMode>
  <FilterMode>
    <Index>3</Index>
    <Option>4x Anisotropic</Option>
    <Setting Index="0">
      <Key>mat_forceaniso</Key>
      <Value>4</Value>
    </Setting>
    <Setting Index="1">
      <Key>mat_trilinear</Key>
      <Value>0</Value>
    </Setting>
  </FilterMode>
  <FilterMode>
    <Index>4</Index>
    <Option>8x Anisotropic</Option>
    <Setting Index="0">
      <Key>mat_forceaniso</Key>
      <Value>8</Value>
    </Setting>
    <Setting Index="1">
      <Key>mat_trilinear</Key>
      <Value>0</Value>
    </Setting>
  </FilterMode>
  <FilterMode>
    <Index>5</Index>
    <Option>16x Anisotropic</Option>
    <Setting Index="0">
      <Key>mat_forceaniso</Key>
      <Value>16</Value>
    </Setting>
    <Setting Index="1">
      <Key>mat_trilinear</Key>
      <Value>0</Value>
    </Setting>
  </FilterMode>
  </Settings>

</CONTENT>

QuestionWeb User Account and login Pin
Addo Henry12-Sep-12 5:34
Addo Henry12-Sep-12 5:34 
AnswerRe: Web User Account and login Pin
Simon_Whale12-Sep-12 5:46
Simon_Whale12-Sep-12 5:46 
QuestionVB(Aplication) Pin
JAFTA11-Sep-12 16:18
JAFTA11-Sep-12 16:18 
AnswerRe: VB(Aplication) Pin
Dave Kreskowiak11-Sep-12 17:31
mveDave Kreskowiak11-Sep-12 17:31 
QuestionHow to get value from database when user chooses month Pin
garyu8711-Sep-12 3:24
garyu8711-Sep-12 3:24 
AnswerRe: How to get value from database when user chooses month Pin
Dave Kreskowiak11-Sep-12 3:44
mveDave Kreskowiak11-Sep-12 3:44 
GeneralRe: How to get value from database when user chooses month Pin
garyu8711-Sep-12 4:01
garyu8711-Sep-12 4:01 
GeneralRe: How to get value from database when user chooses month Pin
David Mujica11-Sep-12 4:28
David Mujica11-Sep-12 4:28 
GeneralRe: How to get value from database when user chooses month Pin
garyu8711-Sep-12 4:47
garyu8711-Sep-12 4:47 
QuestionHow to Display real time ECG in VB6 ? Pin
Nisarg Solanki10-Sep-12 21:01
Nisarg Solanki10-Sep-12 21:01 
AnswerRe: How to Display real time ECG in VB6 ? Pin
Eddy Vluggen11-Sep-12 1:46
professionalEddy Vluggen11-Sep-12 1:46 
Questionpassing parameter in report viewer by using visual studio 2010 Pin
sali2210-Sep-12 18:23
sali2210-Sep-12 18:23 
QuestionSystem Tray Icon Question Pin
RodgerDJr10-Sep-12 7:19
RodgerDJr10-Sep-12 7:19 
AnswerRe: System Tray Icon Question Pin
Wes Aday10-Sep-12 8:12
professionalWes Aday10-Sep-12 8:12 
GeneralRe: System Tray Icon Question Pin
RodgerDJr12-Sep-12 4:53
RodgerDJr12-Sep-12 4:53 
GeneralRe: System Tray Icon Question Pin
Wes Aday12-Sep-12 5:08
professionalWes Aday12-Sep-12 5:08 
QuestionRe: System Tray Icon Question Pin
RodgerDJr12-Sep-12 5:32
RodgerDJr12-Sep-12 5:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.