Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


combining variable value and excel value

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,63811
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> combining variable value and excel value
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 combining variable value and excel value - 8/26/2008 7:15:36 PM   
  rubenv

 

Posts: 4
Score: 0
Joined: 8/26/2008
Status: offline
Hi,
I have following code

ipCounter = 0
for each NetW in NetWSetB
  If not (len(NetW.IPAddress) = 0) then
     if (ipCounter > 0) then
        ipSwitchVar = appExcel.Cells(Row,Colum).Value
        msgbox (ipSwitchVar)
        appExcel.Cells(Row,Colum).Value =  NetW.IPAddress & ", " & ipSwitchVar
     else
        appExcel.Cells(Row,Colum).Value =  NetW.IPAddress
        ipCounter = ipCounter + 1
     end if
  end if
next

As you can see, the first time I encounter an ip address, when ipCounter is still set to zero, I will write that ip address in an excel field.
If however, there is more then 1 ip address (when ipCounter is higher than zero), I will put the value of the excel field in a temporary variable.
Then I will write both the previous ip address (from the temporary variable ipSwitchVar) and the current ip address to the excel field.

This does however not work.
When I move the value of the excel field to ipSwitchVar and then show an msgbox of ipSwitchVar, it shows the correct value.
But when I do this: appExcel.Cells(Row,Colum).Value =  NetW.IPAddress & ", " & ipSwitchVar
It still only shows the first ip address in the excel field.

Now here's the weird thing:
Doing this: appExcel.Cells(Row,Colum).Value =  NetW.IPAddress
WILL show the new ip address in the excel field.
So the problem lies with combining NetW.IPAddress and ipSwitchVar

I have however done this successfully with
appExcel.Cells(Row,Colum).Value =  NetW.MACAddress & ",  " & NetW.Caption
and here it works.

I have no clue what's wrong. Any help would be greatly appreciated.
Thanks,
 
 
Post #: 1
 
 RE: combining variable value and excel value - 8/26/2008 9:04:50 PM   
  rubenv

 

Posts: 4
Score: 0
Joined: 8/26/2008
Status: offline
I will explain by an example.
Suppose I encounter two ip addresses.
192.168.9.1 and 192.168.9.2


if (ipCounter > 0) then
  ipSwitchVar = appExcel.Cells(Row,Colum).Value
  msgbox (ipSwitchVar) => gives 192.168.9.1
  ipSwitchVar = NetW.IPAddress & ", " & ipSwitchVar
  msgbox (ipSwitchVar) => also gives just 192.168.9.1
  appExcel.Cells(Row,Colum).Value = ipSwitchVar

So in the case of putting the two ip addresses together in 1 variable or 1 cell, it only seems to remember, or put in the ip address it encountered before.
However

if (ipCounter > 0) then
  ipSwitchVar = appExcel.Cells(Row,Colum).Value
  msgbox (ipSwitchVar) => gives 192.168.9.1
  ipSwitchVar = NetW.IPAddress
  msgbox (ipSwitchVar) => gives 192.168.9.2
   appExcel.Cells(Row,Colum).Value = ipSwitchVar

So the error must lie with putting the two values together.
I don't understand why because the following works:

for each NetW in NetWSetB
  if not (len(NetW.MACAddress) = 0) then
     If InStr(NetW.Caption, "WAN Miniport") = 0 Then   
        appExcel.Cells(Row,Colum).Value =  NetW.MACAddress & ",  " & NetW.Caption => returns 00:02:B3:D5:83:BA,  [00000010] Intel(R) PRO/1000 XT Server Adapter
        Colum = Colum + 1
     end if
  end if
next

(in reply to rubenv)
 
 
Post #: 2
 
 RE: combining variable value and excel value - 8/28/2008 1:08:50 AM   
  chiltz

 

Posts: 76
Score: 0
Joined: 6/13/2007
Status: offline
Try the below and see if it works.



      

or


      

or


      


(in reply to rubenv)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> combining variable value and excel value Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts