Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-31-2020, 01:55 PM
BobBridges's Avatar
BobBridges BobBridges is offline VBA is conflatng vx and ox! Windows 7 64bit VBA is conflatng vx and ox! Office 2010 32bit
Expert
VBA is conflatng vx and ox!
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default VBA is conflatng vx and ox!

Ok, this is weird. I'm writing a VBA program, and part of it looks like this:



Code:
Set StdXcts = New Collection
For Each oxct In oTSS.Xcts
  bs = (InStr(oxct.Handles, vh) > 0)
  oxct.bStd = bs
  If bs Then
    vx = oxct.Name
    Set ox = New Obj2
    StdXcts.Add ox, vx
    ox.Name = vx
    End If
  Next oxct
Note the part in the middle where I tell it that vx is to become a value (a string), and immediately afterward I set ox to be a new object. Here's the weird thing: As soon as I execute "vx=oxct.Name", both vb and ox become the string ("ARSB"). Then at the next statement, "Set ox=New Obj2", both vx and ox become a new object. Consequently when I try to add ox to the collection using a key of vx, the statement fails.

I stopped the debugger and tried again. I closed the workbook, reopened it and tried again. I closed Excel, then restarted it and tried again. I disconnected from the client machine, reconnected, restarted Excel and tried again. Finally I disconnected, rebooted my own PC and tried again. It's still doing it. So I conclude it's not some temporary difficulty; either it's a bug in the latest version of Excel or my workbook is corrupted.

But before I start trying anything extreme, can anyone imagine any other explanation? Is there anything I could possibly have done earlier in the program that accidentally created an equivalence between vx and ox, for instance?

...Oh, forgot to mention: I tried changing one of the variable names (from ox to oo) and it works!

Last edited by BobBridges; 03-31-2020 at 02:12 PM. Reason: Forgot to say...
Reply With Quote
Reply

Thread Tools
Display Modes


Other Forums: Access Forums

All times are GMT -7. The time now is 03:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft