اسم Module رو بنویس و نقطه بذار، وی بی تمام توابع Module رو واست لیست میکنه .نقل قول:
راه دیگه اینه که اگه تابعی در یک Module به صورت Public تعریف شده باشه، میتونی اون تابع یا فانکشن رو به صورت مستقیم هم صدا بزنی.
Printable View
اسم Module رو بنویس و نقطه بذار، وی بی تمام توابع Module رو واست لیست میکنه .نقل قول:
راه دیگه اینه که اگه تابعی در یک Module به صورت Public تعریف شده باشه، میتونی اون تابع یا فانکشن رو به صورت مستقیم هم صدا بزنی.
یک OCX جالب برای چاپ کردن فرم برنامه که توسط شرکت مایکروسافت ارائه شده است.
[html]http://shalineh.parsaspace.com/Files/PrintForm.zip[/html]
البته این کار با کدنویسی هم مقدوره که بعدا همینجا اونو پست خواهم کرد.
در اینصورت فقط همین فرم رو نمیتونی با دستور Close ببندینقل قول:
که اگه فرم اصلی باشه میتونی با دستور End پروژه رو خاتمه بدی
سلام
در مورد تقویم نخواستم بگویم شما اشتباه میکنید، فقط گفتم کدش را برای عموم بگذارم (گرچه خیلی ساده است!)
در مورد ToolTip و چند مورد دیگر یک پست داده بودم، ولی نمیدانم برای چه از طرف یکی از مدیران حذف شد!
به نظر خودم که ایرادی نداشت! من لحن شوختبعانه را به جدی ترجیح میدهم و همیشه هم از تعادلش سعی میکنم خارج نشوم و تازه حداقل میتوانستند قسمت مشکل دار را ویرایش کنند!
بهر حال حتماً آنها دلیلی داشته اند.
پس فقط در مورد ToolTip باید بگویم که دو راه دارد که ساده ترین آن تنظیم RightToLeft کل فرمتان است، در نتیجه نیازی به مازول خارجی نخواهید داشت.
جابجا کردن فرم بدون نوار عنوان و با قابليت چسبندگی (Dock)
نکته: در اين کد جابجايی توسط کليک بر روی picturebox انجام ميگيره که بجای اون هرچيزی ميشه گزاشت
کد:
'Pic1 as pictureBox
Dim a As Integer
Dim b As Integer
Public ScreenWidth As Integer = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
Public screenHeight As Integer = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
Dim newPoint As New System.Drawing.Point()
Private Sub Pic1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Pic1.MouseDown
a = Control.MousePosition.X - Me.Location.X
b = Control.MousePosition.Y - Me.Location.Y
End Sub
Private Sub Pic1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Pic1.MouseMove
If e.Button = MouseButtons.Left Then
newPoint = Control.MousePosition
newPoint.X = newPoint.X - (a)
newPoint.Y = newPoint.Y - (b)
Me.Location = newPoint
'Docks Form top left and right corners
If Me.Location.X < 8 And Me.Location.Y < 8 Then
Me.Location = New System.Drawing.Point(0, 0)
End If
If Me.Location.X > (ScreenWidth - (Me.Size.Width)) + 8 And Me.Location.Y < 8 Then
Me.Location = New Point(ScreenWidth - Me.Size.Width, 0)
End If
End If
End Sub
شاید یکم از امکانات جدید VB.NET 2005 هم بگیم بد نباشه
شاید این لینک هم بد نیاشه برای انجمن برنامه نویسان هست که یکی از دوستان زحمت اون را کشید بودن
کپی نمی کنم چون کاردرستی نیست با اینکه منبع اغلب اون ها مایکروسافت هست
کد:http://barnamenevis.org/forum/showthread.php?t=19858
اين كد فرم را شبيه يك دايره ميكند
کد:Protected Overrides Sub OnPaint( _
ByVal e As System.Windows.Forms.PaintEventArgs)
Dim shape As New System.Drawing.Drawing2D.GraphicsPath
shape.AddEllipse(0, 0, Me.Width, Me.Height)
Me.Region = New System.Drawing.Region(shape)
End Sub
کد:'Printing Data From ListView
Imports System.Drawing.Printing
Dim tableFont, titlefont, headfont As Font
Dim X1, X2, X3 As Integer
Dim W1, W2, W3 As Integer
Dim Y As Integer
Dim itm As Integer
�I Create this Sub for set the
Fontname,FontSize,Paper Setting
Public Sub PrintBIll()
Dim PSize As Integer = ListItems.Items.Count
Dim PHi As Double
With PrintDocument1.DefaultPageSettings
Dim Ps As PaperSize
PHi = PSize * 20 + 350
Ps = New PaperSize("Cust", 800, PHi)
.Margins.Top = 15
.Margins.Bottom = 20
.PaperSize = Ps
End With
headfont = New Font("Courier New", 16, FontStyle.Bold)
tableFont = New Font("Courier New", 10)
titlefont = New Font("Courier New", 12, FontStyle.Bold)
X1 = PrintDocument1.DefaultPageSettings.Margins.Left
Dim pageWidth As Integer
With PrintDocument1.DefaultPageSettings
pageWidth = .PaperSize.Width - .Margins.Left - .Margins.Right
End With
X2 = X1 + 120
X3 = X2 + pageWidth * 0.5
W1 = X2 - X1
W2 = X3 - X2
W3 = pageWidth - X3
�If u want to print Directly then
PrintDocument1.Print()
�Elseif u want print after print preview then u pls use this code
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
itm = 0
End Sub
�==============================================� �Printing Current Document s Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Y = PrintDocument1.DefaultPageSettings.Margins.Top + 10
e.Graphics.DrawString("INVOICE", headfont, Brushes.Black, X1 + 250, Y)
e.Graphics.DrawString("Cash/Credit Bill ", titlefont, Brushes.Black, X1, Y + 50)
e.Graphics.DrawString("To : " & txtCustomername.Text, titlefont, Brushes.Black, X1, Y + 80)
e.Graphics.DrawString("Date : " & Format(DTsale.Value, "dd-MM-yyyy"), titlefont, Brushes.Black, X1 + 450, Y + 25)
e.Graphics.DrawString("Bill No : " & txtReference.Text, titlefont, Brushes.Black, X1 + 450, Y + 50)
Y = PrintDocument1.DefaultPageSettings.Margins.Top + 120
With PrintDocument1.DefaultPageSettings
e.Graphics.DrawLine(Pens.Black, .Margins.Left, Y + 20, _ .PaperSize.Width - .Margins.Right, Y + 20)
End With
e.Graphics.DrawString("SNO", titlefont, Brushes.Black, X1, Y)
e.Graphics.DrawString("NAME", titlefont, Brushes.Black, X2 - 50, Y)
e.Graphics.DrawString("QTY", titlefont, Brushes.Black, X2 + 220, Y)
e.Graphics.DrawString("RATE", titlefont, Brushes.Black, X2 + 280, Y)
e.Graphics.DrawString("MRP", titlefont, Brushes.Black, X2 + 345, Y)
e.Graphics.DrawString("TOTAL", titlefont, Brushes.Black, X2 + 425, Y)
Y = Y + 30
While itm < ListItems.Items.Count
'Listitems=Listview1
Dim str As String
'str = ListItems.Items(itm).Text
e.Graphics.DrawString(itm + 1, tableFont, Brushes.Black, X1, Y)
str = ListItems.Items(itm).SubItems(1).Text
Dim R As New RectangleF(X2 - 50, Y, W2, 80)
e.Graphics.DrawString(str, tableFont, Brushes.Black, R)
str = ListItems.Items(itm).SubItems(4).Text
Dim k As New RectangleF(X2 + 220, Y, W2, 80)
e.Graphics.DrawString(str, tableFont, Brushes.Black, k)
str = ListItems.Items(itm).SubItems(5).Text
Dim M As New RectangleF(X2 + 235, Y, W2, 80)
e.Graphics.DrawString(str, tableFont, Brushes.Black, M)
str = Format(ListItems.Items(itm).SubItems(7).Text, "Fixed")
Dim N As New RectangleF(X2 + 280, Y, W2, 80)
e.Graphics.DrawString(str, tableFont, Brushes.Black, N)
''''''
str = Format(ListItems.Items(itm).SubItems(6).Text, "Fixed")
Dim L As New RectangleF(X2 + 340, Y, W2, 80)
e.Graphics.DrawString(str, tableFont, Brushes.Black, L)
str = SetSpacing(Format(ListItems.Items(itm).SubItems(8).Text, "Fixed"), 10)
Dim O As New RectangleF(X2 + 400, Y, W2, 80)
e.Graphics.DrawString(str, tableFont, Brushes.Black, O)
Dim lines, Cols As Integer
e.Graphics.MeasureString(str, tableFont, New SizeF(W2, 50), _ New StringFormat(), Cols, lines)
Dim Yc As Integer
Yc = Y
Y = Y + lines * tableFont.Height + 5
Y = Math.Max(Y, Yc)
itm = itm + 1
End While
e.Graphics.DrawString("Net Amount : " & SetSpacing(Format(txtNetAmount.Text, "Fixed"), 10), titlefont, Brushes.Black, X2 + 240, Y + 15)
e.Graphics.DrawString("Roundof : " & SetSpacing(Format(txtRounof.Text, "Fixed"), 10), titlefont, Brushes.Black, X2 + 240, Y + 35)
e.Graphics.DrawString("Paid Amount : " & SetSpacing(Format(txtPaymentAmount.Text, "Fixed"), 10), titlefont, Brushes.Black, X2 + 240, Y + 55)
e.Graphics.DrawString("Balance : " & SetSpacing(Format(txtbalance.Text, "Fixed"), 10), titlefont, Brushes.Black, X2 + 240, Y + 75)
e.Graphics.DrawString("", titlefont, Brushes.White, X2 + 240, Y + 105) End Sub
پیدا کردن IP Address
کد:Dim h As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName)
Console.WriteLine(CType(h.AddressList.GetValue(0), IPAddress).ToString)
تبديل مبناي 2 به 10 در VB.NET
کد:Dim a, x, i, sum As Integer
i = 1
sum = 0
a = TextBox1.Text()
While (a <> 0)
x = a Mod 10
a = a / 10
sum += x * i
i *= 2
End While
MessageBox.Show(sum)