Re: vb.net search network drive



On Mar 14, 5:17 pm, ShaneO <spc...@xxxxxxxxxxxxxxx> wrote:
Computer geek wrote:
The purpose of this program is to check various system functions at
the beginning of the day. The first one I'm doing is to check for fax
files that did not get sent over night. This is what I have so far:

Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnStart.Click

'Checks network drive for files of .fax type
Dim sFiles() As String = System.IO.Directory.GetFiles("K:
\AutoFax\", String.Format("*.{0}", "fax"))

'Displays the number of fax files in the listbox
lstResults.Items.Add(String.Format("There are " &
UBound(sFiles) + 1 & " fax files waiting to be sent"))

End Sub

Ideally, I'd like to use an IF statment to test if the are more than 0
files to display what I have above. And if not, display a differnt
message. But I was not able to get an IF statement to work. I think it
has something to do with how you test a String value... The reason I
asked about pausing was because after it does the check for faxes,
I'll want it to pause briefly before moving to the next step. Just so
the display doesn't fill up real fast.

Why not just place a Label above your ListBox, that way the Label won't
scroll-off the page if there's a lot of files being listed -

Dim sFiles() As String = System.IO.Directory.GetFiles("K:\AutoFax\",
"*.fax")
If sFiles.Length > 0 Then
Label1.Text = String.Format("There are {0} fax files waiting to be
sent", sFiles.Length)
Else
Label1.Text = "All faxes have been successfully sent."
End If

Note the following points:

1. I've removed your String.Format function from the first line. It was
illogical to use it with a known value like "fax". If you know the
value, then just use it in the string.
2. I've included the "If" that you mentioned you wanted.
3. Generally, watch out for the way you're using "String.Format". Take
another look at your second line.
4. This may be a little ahead of you at this time, but, if you decide to
use the Label option I've suggested and you're going to check for
additional files, do your next check and just add to the already
displayed Label Text. eg. - Label1.Text = Label1.Text & vbCrLf &
String.Format("There are also {0} whatever files waiting to be sent",
sWhatever.Length)

I hope this helps you.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.- Hide quoted text -

- Show quoted text -

Do either of you know of any good online resources that clearly define
different functions/methods in vb.net? I've found a couple sites but
they are not very intuitive for a beginner like myself.

.



Relevant Pages

  • Re: vb.net search network drive
    ... files to display what I have above. ... has something to do with how you test a String value... ... Why not just place a Label above your ListBox, that way the Label won't scroll-off the page if there's a lot of files being listed - ... String.Format("There are also whatever files waiting to be sent", ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Cant display label text
    ... This is driving me crazy!! ... If you change it to display a message box is there actually a name in the ... Are the label width and height greater than zero? ... >> private void AddPathAndCallCompactDB(string dbFolder, string systemDB, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: compare string lenth to text box drawing area
    ... Here is some code that will find out if a string fits in a label, ... doesn't, display it in a dynamically placed label that's wider, and covers ... > How can I determine if a string will fit in the display area of a text ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Format text from db into HTML text
    ... The textbox formatting is done by setting mode to Multiline obviously, ... > I am then assigning this string variable to an HTML control, either Label ... > And while I'm on the subject, is there an easy way to display RTF text in ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: A Simple BMP Converter
    ... "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal ... Private Sub cmdSysInfo_Click ... Open Registry Key ... > color bar in the color display. ...
    (comp.lang.basic.visual.misc)