excel - Error 91 on Frame Control upon Start Up -
i have microsoft form 2.0 frame control 3 option buttons. name of frame control side, 3 option button captions x, o, , random names xoption, ooption, , randomside respectively. code runs fine, except upon startup, if open excel , run program immediately, give me error 91, note 1 of options (x, o, or random) selected. in order rid of error, need explicitly select option, error goes away. don't know why happens. here sub frame control
public sub side_click() sideletter = side.activecontrol.caption if strcomp(sideletter, "random") = 0 randomize temprand = int((rnd() * 2 + 1)) if temprand = 1 sideletter = "x" else sideletter = "o" end if end if end sub the line sideletter = side.activecontrol.caption 1 causing issue. have not explicitly declared side frame control in case that's helpful information because i'm thinking object declared making frame control. in advance!
you need check side.activecontrol object, before read it's caption:
public sub side_click() if not side.activecontrol nothing sideletter = side.activecontrol.caption if strcomp(sideletter, "random") = 0 randomize temprand = int((rnd() * 2 + 1)) if temprand = 1 sideletter = "x" else sideletter = "o" end if end if end if end sub
Comments
Post a Comment