Jump to content
Xtreme .Net Talk

nbrege

Avatar/Signature
  • Posts

    34
  • Joined

  • Last visited

Everything posted by nbrege

  1. Suppose I have an array of 500 strings that I want to print out on multiple pages. I started with the code below, but I just cant figure out how to make it print the first pageful, invoke the .HasMorePages property & then continue printing the next page of items, and so forth, until all the elements in the array are printed. I have tried setting the .HasMorePages property to True when the print location reaches the bottom of the page, but then my loop starts over at the beginning again, giving the same output for all pages. I know I am close but I just can't figure how to do this. Can anyone help me get this working? Private Sub PrintDocument2_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument2.PrintPage Dim printFont As New Font("Arial", 12) Dim lineHeightSingle As Single = printFont.GetHeight + 2 Dim horizontalPrintLocationSingle As Single = e.MarginBounds.Left Dim verticalPrintLocationSingle As Single = e.MarginBounds.Top ' Count pages for multiple-page output. Static pageCountInteger As Integer = 1 ' Print the page number. e.Graphics.DrawString("Page " & pageCountInteger.ToString(), printFont, Brushes.Black, 600, verticalPrintLocationSingle) verticalPrintLocationSingle = verticalPrintLocationSingle + lineHeightSingle * 2 For xInt As Integer = 1 To 500 ' Print a line. e.Graphics.DrawString("This is line " & xInt.ToString, printFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle) ' Double space. verticalPrintLocationSingle = verticalPrintLocationSingle + lineHeightSingle * 2 Next End Sub Thanks for your help...
  2. Is there a way to retrieve the owner of a file that resides on a network? I know how to retrieve the other attributes, such as file size, last write time, etc., but I dont know how to get the owner. Can someone help me with this or provide a code example? This is in VB2005 Express. Thanks...
  3. Can you give an example? I'm not familiar with Regex. Thanks...
  4. I have a string that represents a part number. The part number is always a 5 or 6 digit number, such as "35292" or "105468". Optionally, the 5 digit part numbers could have a suffix such as "37023-BF". I am trying to find a way to get just the numerical portion of the part number string whether it is 5 or 6 digits & has a suffix or not. The first character of the suffix will always be a dash ("-"), if that helps any. I have tried the parse & convert methods but they error out on the strings with suffixes. Can anyone provide me with a solution to this problem? Thanks...
  5. Thanks for the suggestions. I ended up using the following: filetmp = Microsoft.VisualBasic.Left(filename, InStrRev(filename, ".") - 1) this seems to do the trick...
  6. What's the best way to strip an extension from a filename? If I have the string MyString = "MyFile.txt" , how can I get just "MyFile"? I know this is an easy one, but I'm fairly new to VB. Thanks...
  7. I am writing a program that watches a certain folder for incoming files & then moves those files to another folder. Here's the problem: if I copy a group of files into the watched folder it works fine, but if I move a group of files into the watched folder it doesn't do anything, the event handler never triggers. What is the proper notify filter to use to watch for new files in a folder? I have tried both the Size & LastWrite filters but neither does what I want. Any help would be appreciated. Here is the code I have so far: Imports System.IO Imports System.Diagnostics Public Class Form1 Const watchfolder As String = "c:\checked" Const targetfolder As String = "c:\checked2" Dim fsw As New FileSystemWatcher(watchfolder) Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' Watch for changes in folder size fsw.NotifyFilter = (NotifyFilters.LastWrite) ' Register a handler that gets called when a file is created, changed, or deleted. AddHandler fsw.Changed, New FileSystemEventHandler(AddressOf OnChanged) ' Begin watching. fsw.EnableRaisingEvents = True End Sub Private Sub OnChanged(ByVal source As Object, ByVal e As FileSystemEventArgs) ' folder contents have changed Console.Beep() ' Create a reference to the current directory. Dim di As New DirectoryInfo(watchfolder) ' Create an array representing the files in the current directory. Dim fi As FileInfo() = di.GetFiles() Console.WriteLine("The following files exist in the current directory:") ' Print out the names of the files in the current directory. Dim fiTemp As FileInfo For Each fiTemp In fi Console.WriteLine(fiTemp.Name) My.Computer.FileSystem.MoveFile(watchfolder & "\" & fiTemp.Name, targetfolder & "\" & fiTemp.Name, True) Next fiTemp End Sub Thanks...
  8. Actually I got it figured out. I used the Insert Snippet feature & it gave me exactly what I needed. Thanks...
  9. I an trying to write some code to send an email message from VB 2005 Express. I found some code examples for VB.net but I am having trouble converting it to work in VBX. Could someone please provide me with a code example that will work. Thanks...
×
×
  • Create New...