Login | |
|
 |
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,
|
|
| |
|
|
|
 |
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
|
|
| |
|
|
|
|
|