
a_jam_sandwich
Avatar/Signature-
Posts
371 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by a_jam_sandwich
-
Right ive made this version now it works the same as iebidans code just a lot shorter. Ive also commented each line on printing Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage ' Create a varible called CurrentLine this is static so when the function is ' Recalled the value of CurrentLine stays the same. Static CurrentLine As Integer ' Split the contents of the textbox up into lines Dim TextboxLines() As String = Split(TextBox1.Text, vbCrLf) ' Make a rectangle with the printer bounds. Dim MyPrintRectangle As New RectangleF(e.PageBounds.X + e.PageSettings.Margins.Left, e.PageBounds.Y + e.PageSettings.Margins.Top, e.PageBounds.Width - (e.PageSettings.Margins.Left * 2), e.PageBounds.Height - (e.PageSettings.Margins.Top * 2)) ' Set the Offset for the firstline printed. Dim PrintY As Integer = MyPrintRectangle.Y ' Varible to hold the Height of each line. Dim SizeF As New SizeF ' Start the loop do draw the textbox contents line by line. While CurrentLine < UBound(TextboxLines) ' Measure the string height SizeF = e.Graphics.MeasureString(TextboxLines(CurrentLine) & vbCrLf, Me.Font, MyPrintRectangle.Width, New StringFormat) ' Check if the text is bigger than the page allows from the offset pos ' if it is set HasMorePages to true and exit the loop If PrintY > MyPrintRectangle.Height Then e.HasMorePages = True Exit While End If ' Draw the line to the printer e.Graphics.DrawString(TextboxLines(CurrentLine), Me.Font, New SolidBrush(Color.Black), New RectangleF(MyPrintRectangle.X, PrintY, MyPrintRectangle.Width, SizeF.Height)) ' Add this Height to the Offset of the draw cursor PrintY += SizeF.Height '+ ReturnChar ' Set the CurrentLine to +1 to read the next line in the textbox.text CurrentLine += 1 End While End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click PrintPreviewDialog1.Document = PrintDocument1 PrintPreviewDialog1.Show() End Sub Andy
-
Right heres basic This will not do multiple pages it will print the contents on textbox1.text and that is it. Add a button. textbox, PrintDocument and PrintPreviewDialog Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage ' Make a rectangle with the printer bounds. Dim MyPrintRectangle As New RectangleF(e.PageBounds.X + e.PageSettings.Margins.Left, e.PageBounds.Y + e.PageSettings.Margins.Top, e.PageBounds.Width - (e.PageSettings.Margins.Left * 2), e.PageBounds.Height - (e.PageSettings.Margins.Top * 2)) e.Graphics.DrawString(TextBox1.Text, Me.Font, New SolidBrush(Color.Black), MyPrintRectangle) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click PrintPreviewDialog1.Document = PrintDocument1 PrintPreviewDialog1.Show() End Sub That is the most basic your going to make it Andy
-
If you want an application created in 1.1 to work on 1.0 then yes add a config file and specify that. If you have an application created in 1.0 framework and have the 1.1 framework installed on the target PC then you don't have to include a config file. Andy
-
Missing ; somewhere in SQL...help!!!
a_jam_sandwich replied to dakota97's topic in Database / XML / Reporting
The problem seems in your SQL you are trying to run a where clause on an INSERT query if your updating then use the UPDATE sql command other wise remove the WHERE statment in the above query Andy -
Look at me site :D
-
Check out the AssemblyInfo file you can change the version by changing the AssemblyVersion number Andy
-
No one have any ideas?
-
Im just messing around with sockets as uptill now I not really touched it. Anyway I want to create a server query tool for halflife servers. Here is the code so far very simple as you will see Dim MyUDP As New UdpClient Dim MyIP As IPAddress = IPAddress.Parse("195.149.21.70") MyUDP.Connect(MyIP, 27015) Dim Command As [byte]() Command = Encoding.ASCII.GetBytes(Chr(255) & Chr(255) & Chr(255) & Chr(255) & "players") MyUDP.Send(Command, Command.Length) Console.WriteLine("Sent") Dim RemoteIpEndPoint As New IPEndPoint(MyIP, 27005) Try Dim receiveBytes As [byte]() = MyUDP.Receive(RemoteIpEndPoint) Dim returnData As String = Replace(Encoding.ASCII.GetString(receiveBytes), Chr(0), "|") Console.WriteLine(returnData) Catch ex As Exception Console.WriteLine(ex.ToString()) End Try MyUDP.Close() The problem is Im not receiving any packets back the protocol is as from I have done this in PHP and it worked. http://phxx.net/faq.asp?pid=22 Anyone have any ideas Thanks Andy
-
Problems with Excel 2000
a_jam_sandwich replied to a_jam_sandwich's topic in Interoperation / Office Integration
For anyone who may of experienced the problem above the problem occurs using 10.0 excel object in Excel 2000. The way I have solved this is to late bind the excel object and sure enough worked perfectly Andy. -
LOL, this post is making me laugh. All you need to do is post your errors. I think it probley takes more effect to moan than do this simple task. By the way there being pushy and just dam impolite, you figure. Andy
-
Currently I have a problem with excel running the code below works on Excel 2002 but on Excel 2000 is creates and exception nullreferenceexception : Object reference to set to instance of object Im using the 10.0 excel comm object oExcel As New Excel.Application ' This is the line where it fails to open the file. oExcel.Workbooks.OpenText("C:\test.csv", Type.Missing, 1, Excel.XlTextParsingType.xlDelimited, _ Excel.XlTextQualifier.xlTextQualifierNone, _ Type.Missing, Type.Missing, Type.Missing, True, Type.Missing, _ Type.Missing, Type.Missing, Type.Missing, Type.Missing, _ Type.Missing, Type.Missing, Type.Missing, Type.Missing) ' (Filename, StartRow:=3, DataType:=Excel.XlTextParsingType.xlDelimited, Comma:=True) oExcel.visible = True oExcel = Nothing Anyone have any ideas? Thx Andy
-
As long as MDac2.6 or later is installed on the target then your installation will work and everything will function the version of Access being run doesnt make a diffrence. Jet4.0 is just a connection provider allowing you to communicate with the database. Regards Andy
-
on the click event you should first check if anything is selected within the listview If ListView1.SelectedItems.Count > 0 Then ' Do somthing ... End If That should stop your error Andy
-
Application.ProductVersion.ToString This will give you the build number of the project you are making located in the AssemblyInfo Version.ToString will give you the framework version its running on Regards Andy
-
Withevent variable does not raise any event?
a_jam_sandwich replied to Worrow's topic in Windows Forms
Worrow, if you will not be able to create an array of buttons to build the form it the way you described as you cannot assign WithEvents to an array. I have however knocked you an example of how to add the buttons to a form dynamically based on how many buttons are selected. See file attached to this post. Regards, Andy create buttons.zip -
Insert a empty datetime field
a_jam_sandwich replied to Datahighway's topic in Database / XML / Reporting
Use SQL like this All you do as above is enter NULL as the value in the SQL Regards Andy -
Im currently writing a new control but having some trouble The problem is that the control items are populated from collectionbase as below Public Class MemoItemCollection : Inherits CollectionBase Public Sub New() End Sub Public Function Contains(ByVal Item As MemoItem) As Boolean Return MyBase.List.Contains(Item) End Function Default Public ReadOnly Property Item(ByVal Index As Integer) As MemoItem Get Return CType(MyBase.List.Item(Index), MemoItem) End Get End Property Public Function Add(ByVal Item As MemoItem) As MemoItem MyBase.List.Add(Item) Return CType(Item, MemoItem) End Function Public Overloads Sub Remove(ByVal Item As MemoItem) MyBase.List.Remove(Item) End Sub End Class Memo item is a simple class with Header, Body and Tag as propertys ok heres the problem I now have a control that uses the above collectionbase using the following code ... Private _MemoCollection As New MemoItemCollection And the property ive given the control is ... <Category("Items")> _ Public Property MemoItems() As MemoItemCollection Get Return _MemoCollection End Get Set(ByVal Value As MemoItemCollection) _MemoCollection = Value End Set End Property I can add the MemoItems in the designer no problem save and exit VS.NET when I reopen the solution and look in MemoItems in the custom control all the Items have disapeared. I have no real idea whats happening this is my first attempt at writing a collectionbase control Thx in advance Andy :p
-
When running a procedure within a button event the event expects 2 things one is the sender and the other is event args by adding these you can run the code. ' The sender is set as me and for the EventArgs you create new ones btnCancel_Click(Me, New EventArgs) I hope this helps Andy
-
Use the following Replace(Textbox1.Text, "'", "''") At the point in your sql add this command, Change Textbox1.text to whatever your textbox is named Andy
-
Nice and easy m8 Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs) ' Check Number of MDI Child windows if any Cancel close and Show Msgbox If Me.MdiChildren.Length > 0 Then MsgBox("Cannot Close") e.Cancel = True End If End Sub Add this into the MDI parent. Andy
-
Accepting external argument(s) in Form application
a_jam_sandwich replied to Hughng's topic in General
Nice and Easy ... Environment.GetCommandLine e.g you run myapp.exe -h in vb.net msgbox(Environment.GetCommandLine) ' Returns -h You can of course use Environment.GetCommandLineArgs() Which is a array of the arguments Andy -
Types are now sturctures in .net have a look at the vb help files but the syntax is like the following Private Structure Data Public Data1 as Integer End Structure Andy
-
I could be a virus the blaster.worm Fixes anti-virus tool.... http://securityresponse.symantec.com/avcenter/FixBlast.exe Windows 2000 patch for exploit http://download.microsoft.com/download/0/1/f/01fdd40f-efc5-433d-8ad2-b4b9d42049d5/Windows2000-KB823980-x86-ENU.exe Windows XP patch for exploit http://download.microsoft.com/download/9/8/b/98bcfad8-afbc-458f-aaee-b7a52a983f01/WindowsXP-KB823980-x86-ENU.exe All havock broke out here when the RPC error appeared on lots of PCs at work ARRRHHH!!! Andy
-
It happening on mine too weird