Question: I have a combobox that is bind with a datasource and I am inserting a blank value to the 0 index like below.

```
 Private Sub BuildCustomerList()
        Dim ID As String = CStr(Session("M3_CustomerID"))
        Dim fCustID As Guid = Guid.Parse(ID)
        Dim dt As DataTable = dbAccess.GetCustomerRecord(fCustID)

        'Set initial user display settings
        cmbSelectCustomer.DataValueField = dt.Columns(0).ToString()
        cmbSelectCustomer.DataTextField = dt.Columns(1).ToString()
        cmbSelectCustomer.DataSource = dt
        cmbSelectCustomer.DataBind()
        cmbSelectCustomer.Items.Insert(0, New ListItem(String.Empty, DBNull.Value.ToString()))
        ', (Guid.Empty).ToString()))
        cmbSelectCustomer.SelectedIndex = 0
    End Sub

```

There is a method that accept guid type parameter as given below

```
 Private Sub PopulateManageMessageGridView(ByVal customerID As Guid?)

   End Sub

```

For here i have to pass a Guid? type value or Guid value as given below

```
PopulateManageMessageGridView(Guid.Parse(cmbSelectCustomer.SelectedValue)) 

```

but when cmbselectCustomer.selectedValue is string.empty("") then it given error something like this **"Unrecognized Guid format."**

So how to convert string.empty to guid ? so method accept the parameter. Any help will be appreciated. thanks in advance

Answer: 
Just check it:

```
Dim customer = cmbSelectCustomer.SelectedValue
Dim guid As Guid
If String.IsNullOrEmpty(customer) Then 
    guid = Guid.Empty
Else
    guid = Guid.Parse(customer)
End If
PopulateManageMessageGridView(guid) 

```

You could also use `Guid.TryParse`:

```
Dim customer = cmbSelectCustomer.SelectedValue
Dim guid As Guid
If Not Guid.TryParse(customer, guid) Then guid = Guid.Empty
PopulateManageMessageGridView(guid) 

```

Maybe you want to call that method only if the string is not empty:

```
If Not String.IsNullOrEmpty(customer) Then 
    PopulateManageMessageGridView(Guid.Parse(customer)) 
End If

```
I'm always a fan on less code.

```
Dim cb As New ComboBox
Dim guid As Guid = If(cb.SelectedIndex > 0, guid.Parse(cb.SelectedValue), guid.NewGuid())

```

We check the `SelectedIndex` property of the ComboBox and confirm it is greater than 0, which will also handle the case that nothing is selected (index is -1).

While it is smart to assign a new guid to the record with `guid.NewGuid()`, you could also use `guid.Empty` which will return 00000000-0000-0000-0000-000000000000

In your question you stated that you have the empty string value at index 0, but for completeness, I will address if you had multiple records with an empty string value. In such a case, check on the `SelectedValue` instead of the `SelectedIndex` of the ComboBox in the ternary statement:

```
Dim guid As Guid = If(cb.SelectedValue.Length > 0, guid.Parse(cb.SelectedValue), guid.NewGuid())

```