0

Why below code has error in VB.net 2008?

Dim Object1 As New Class1

Object1.SetId = If(rbSet.Checked = True, Convert.ToInt32(txtSetId.Text.Trim()), DBNull.Value)

What I'm trying is to set a property of an object by a condition.

odiseh
  • 25,407
  • 33
  • 108
  • 151

1 Answers1

2

Use Nothing

Object1.SetId = If(rbSet.Checked = True, Convert.ToInt32(txtSetId.Text.Trim()), Nothing)
KV Prajapati
  • 93,659
  • 19
  • 148
  • 186