Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21136

VBA Variables... Help!

$
0
0
Hello Gents

I am having some issues with my code so am needing some help.

Background is im using VBA (i know its horrible but it has to be used for this task),
I have a GUI that the user deals with, there are multiple text input boxes. the user will input several numbers and hit my 'Get_values' button.

So if i focus on 1 text box named 'mobelenum'. i want the user to be able to input a number say 5, in to this box. I then want to be able to use this value of '5' to then input in to a XML search...

pulling the data out of XML isnt too hard, but im finding it hard to get the users input value into my code.... so here is a very small example of what i have been trying to do .


Quote:

Private Sub Get_Values_Click()

'this inputes the value written from user in to cell Z2 on sheet 1.
Worksheets("sheet1").Range("Z2").Value = mobelenum.Value

' Here i want to declare that mobvar will be an Integer
Dim mobvar As Integer

'Now setting the Value associated with mobvar (in this case the number 5)
mobvar = Worksheets("sheet1").Range("Z2").Value

Set oXML = CreateObject("MSXML.DOMDocument")
oXML.async = False
oXML.Load ("c:\\......._17-32-20.xml")
Worksheets("sheet1").Range("B2").Value = oXML.DocumentElement.SelectSingleNode("Header/description").nodeTypedValue
Worksheets("sheet1").Range("B3").Value = oXML.DocumentElement.SelectSingleNode("Header/domain").nodeTypedValue
Worksheets("sheet1").Range("B4").Value = oXML.DocumentElement.SelectSingleNode("Header/date").nodeTypedValue
Worksheets("sheet1").Range("B5").Value = oXML.DocumentElement.SelectSingleNode("Header/version").nodeTypedValue
Worksheets("sheet1").Range("B6").Value = oXML.DocumentElement.SelectSingleNode("Header/author").nodeTypedValue
Worksheets("sheet1").Range("B7").Value = oXML.DocumentElement.SelectSingleNode("Header/source").nodeTypedValue


'Now this is the bit im getting stuck on.... i want to input the value of mobvar (user inputted number) to then complete the code so that the correct data associated with MobileNumber 5 is exctracted from the XML file.
Worksheets("sheet1").Range("B8").Value = oXML.DocumentElement.SelectSingleNode("TableContents/MobileNumber[@MobileNumber='mobvar' '']/IPNumber").nodeTypedValue
any help would be great as im a complete noob when it comes to extracting XML data using VBA.

Thanks!

Smerf

Viewing all articles
Browse latest Browse all 21136

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>