0

Basically I have a form that I want to auto populate based on the results of some boolean statements. Such as "IF true then celcius radiobutton is checked"

What I have so far is the following

Public Class Unitsofmeasureform Dim oForm As Unitsofmeasureform

Public Sub Load_Units_Form()
    'Dim ws As Object
    'ws = Application.activesheet()

    Dim xlApp
    xlApp = Application
    Dim temp_units As String



    If IsNothing(oForm) OrElse oForm.IsDisposed Then
        oForm = New Unitsofmeasureform()
    End If
    oForm.Show()


    temp_units = Application.Sheets("units sheet").Range("D1").value
    If temp_units = "°C" Then

        Application.Sheets("sheet1").range("A1") = 1
        Me.celcius.Checked = True
    Else
        Application.Sheets("sheet1").range("A1") = 2
        Me.fahrenheit.Checked = True
    End If

End Sub

I am using a program called ExcelDNA to integrate this VB.net form into excel and I have included to the range information to ensure that the if statement works. However when the form reloads the radiobutton with the tag celcius is no checked. nor is it checked when i repeat the code without "Me."

found my own solution

change the

Me.celcius.Checked = True

to

oForm.celcius.Checked = True

then this works

  • How are you getting hold of the Application object? With Excel-DNA you need to get it from a call to ExcelDnaUtil.Application to be sure you get hold of the right Excel instance. – Govert Nov 14 '13 at 20:35
  • Govert, I have used the ExcelDna.Integration & ExcelDna.Integration.ExcelDnaUtil and I know it is getting the object from the sheet because it is correctly populate the Application.Sheets("sheet1").range("A1"). It is something to do with populating the radiobutton on the form – user2978403 Nov 14 '13 at 21:30
  • If you found the solution, you can post it as an answer so future viewers can have an easier time of seeing it. – SuperPrograman Nov 14 '13 at 22:59
  • sorry I couldn't post as an answer to my own question due to my new status – user2978403 Nov 14 '13 at 23:41
  • Ahh, @user2978403, that's OK. Sorry, that was my fault, forgot about that. – SuperPrograman Nov 18 '13 at 04:39

0 Answers0