Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21273

What to do if the textbox is blank?

$
0
0
Hi there everyone!

I am working on a program where students makes cards with numbers, the program saves them so I can view their work later.

I use a textbox. I type in the name of their file, and their number card is opened, but in the case that the textbox searching is blank, or I mispell the name, I will get a file not found error, and I understand why.

I was just wondering if there was a way so if by some reason I forget to enter a file name, or if the name is incorrect, I would just get a msgbox saying file not found, and have the program not stop?

I use this code to search.

VB Code:
  1. 'This code will load the card numbers
  2. NumberList.Clear
  3. Dim text As String
  4.     Open App.Path & "\GeneratedCards\" & CardNumberTXT.text & ".txt" For Input As #1
  5.     Do Until EOF(1)
  6.     Input #1, text
  7.     NumberList.AddItem text
  8.     Loop
  9.     Close #1

The CardNumberTXT.text is where I search, but is there a way to have an if then statement where if it was blank, or if the file is not found, it would give me a msgbox instead ? THANKS!!

Viewing all articles
Browse latest Browse all 21273

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>