---
title: "Set a character variable with an if - then statement"  
description: "Set a character variable with an if - then statement"  
author: "Jayden Bell"  
published: 2013-06-11  
updated: 2013-06-12  
canonical: https://www.mindstick.com/forum/1029/set-a-character-variable-with-an-if-then-statement  
category: "vb.net"  
tags: ["vb.net"]  
reading_time: 1 minute  

---

# Set a character variable with an if - then statement

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances),\
How to set a [variable](https://www.mindstick.com/articles/1807/objective-c-data-types-variables-object-creation), **typeofauction**, as either '**a**' or '**f**' with an if then statement. [dim](https://www.mindstick.com/interview/561/what-is-the-difference-between-the-dim-public-and-private-statements) **typeofauction** as char. I'm [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) as following \
**typeofauction = typeofauction1.Text** **If (typeofauction = "Auction") Then** **listingtype = 'a'** **[End](https://yourviews.mindstick.com/view/88503/us-iran-war-live-updates-trump-says-us-in-no-rush-to-end-iran-war) If** **If (typeofauction = "Fixed Price") Then** **listingtype = 'f'** **End If****\**What [wrong](https://answers.mindstick.com/qa/48468/who-wrote-the-the-wrong-enemy-america-in-afghanistan-2001-2014-and-when) with above line of code.Please help.Thanks in advance.

## Replies

### Reply by AVADHESH PATEL

Hi Jayden,\
You say you are trying to set **typeofauction**, which is defined as a char type, to '**a**' or '**f**'. However, your code shows you are trying to set **listingtype** which appears to be a char.\
I think you have your types confused. Try:\

```
Dim listingtype As CharDim typeofauction As String = typeofauction1.Text ' assuming this is a textboxIf typeofauction = "Auction" Then   listingtype = "a"cElseIf typeofauction = "Fixed Price" Then   listingtype = "f"cEnd If
```

**\**You don't have to use the Char type for listingtype. You can also use a String which will simply hold only one character.


---

Original Source: https://www.mindstick.com/forum/1029/set-a-character-variable-with-an-if-then-statement

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
