Hi folks. Can't seem to understand why there is an extra line created with my appendtext code at the end. This creates empty records at the top of the listbox after every new phone list added.

I also have a problem with the inputbox message display where there are a number of "," appearing!

The (brief) pseudocode is:-
Open file with Phone Dir's
Display Ph Dir for use to choose via input box
If PD not exist ask if user wants to create it
If yes then create file & add to PD list

BTW I have a Dim sw As Streamwriter at the top. (I may put it with the actual AppendText code for clarity later on.)

VB Code:
  1. SortData(temp, counter) 'sort data
  2.  
  3.     lstOutput.Items.Clear() 'Clear listbox
  4.     'Display PhDir List
  5.     For i = 1 To counter
  6.       lstOutput.Items.Add(temp(i))
  7.     Next
  8.  
  9.     'Create list for input box for user to choose/create phonelist
  10.     For i = 1 To counter
  11.       dirList = dirList & ", " & temp(i)
  12.     Next
  13.  
  14.     'prompt user for phonelist
  15.     prompt = "Enter phone directory: " & dirList
  16.     fn = InputBox(prompt).ToUpper
  17.     'search for name
  18.  
  19.     'Search for file
  20.     If File.Exists(f & fn) Then
  21.       sw = File.AppendText(f & fn)
  22.       sw.WriteLine(name)
  23.       sw.WriteLine(number)
  24.       sw.Close()
  25.     Else 'If file does not exist ask user if they want to create it
  26.       r = MsgBox("File Not Found! Do you want create a new phonelist?", MsgBoxStyle.YesNoCancel, vbYesNoCancel)
  27.       If r = vbYes Then
  28.         sw = File.AppendText(f & fn)
  29.         sw.WriteLine(name)
  30.         sw.WriteLine(number)
  31.         sw.Close()
  32.       End If
  33.       Dim exists As Boolean = False
  34.       For i = 1 To counter
  35.         If fn = temp(i) Then
  36.           exists = True
  37.         End If
  38.       Next
  39.       If exists = False Then 'Write new PhDir to PhDir file list
  40.         sw = File.AppendText(f & pL)
  41.         sw.WriteLine(fn)
  42.         sw.Close()
  43.       Else
  44.       End If
  45.     End If