|
|
Don't forget to clear previous image, and there's no filepath property in the openfiledialog, remember that. So use filename instead.
pictbox.Image = Nothing<br />
pictbox.Image = image.fromfile(openfiledialog.filename)
|
|
|
|
|
I was wondering if anyone knows how I can create a DB Job and schedule it to run automatically at reqular intervals, from VB .NET code. I am trying to write an application side interface to the scheduling system that is available in the MSSQL Server 2005, SQL Agent.
I have been looking for information on this for awhile now and anyhelp would be much appreciated.
Thanks.
|
|
|
|
|
Hi,
I want to change the back color of selected date in monthcalander.
Thanks in advance.
|
|
|
|
|
Help me.
How can i print a word document (e.g. one.doc) by clicking on a Click event of a Button in VB.Net ?
Annu Yadav
|
|
|
|
|
|
You can use this, and change the filepath as you need:
<br />
Private printFont As Font<br />
Private streamToPrint As StreamReader<br />
Private Shared filePath As String<br />
--------------------------------------------------<br />
' The PrintPage event is raised for each page to be printed.<br />
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)<br />
Dim linesPerPage As Single = 0<br />
Dim yPos As Single = 0<br />
Dim count As Integer = 0<br />
Dim leftMargin As Single = ev.MarginBounds.Left<br />
Dim topMargin As Single = ev.MarginBounds.Top<br />
Dim line As String = Nothing<br />
<br />
' Calculate the number of lines per page.<br />
linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)<br />
<br />
' Iterate over the file, printing each line.<br />
While count < linesPerPage<br />
line = streamToPrint.ReadLine()<br />
If line Is Nothing Then<br />
Exit While<br />
End If<br />
yPos = topMargin + count * printFont.GetHeight(ev.Graphics)<br />
ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, _<br />
yPos, New StringFormat())<br />
count += 1<br />
End While<br />
<br />
' If more lines exist, print another page.<br />
If Not (line Is Nothing) Then<br />
ev.HasMorePages = True<br />
Else<br />
ev.HasMorePages = False<br />
End If<br />
End Sub<br />
------------------------------------------<br />
' Print the file.<br />
Public Sub Printing()<br />
Try<br />
streamToPrint = New StreamReader(app_path & "\data.txt")<br />
Try<br />
printFont = New Font("Arial", 10)<br />
Dim pd As New PrintDocument()<br />
AddHandler pd.PrintPage, AddressOf pd_PrintPage<br />
' Print the document.<br />
pd.Print()<br />
Finally<br />
streamToPrint.Close()<br />
End Try<br />
Catch ex As Exception<br />
MessageBox.Show(ex.Message)<br />
End Try<br />
End Sub 'Printing <br />
<br />
' This is the main entry point for the application.<br />
Public Shared Sub Main()<br />
Dim args() As String = System.Environment.GetCommandLineArgs()<br />
Dim sampleName As String = args(0)<br />
If args.Length <> 1 Then<br />
Console.WriteLine("Usage: " & sampleName & " <file path>")<br />
Return<br />
End If<br />
filePath = args(0)<br />
End Sub<br />
add to your click event this:
Private Sub btnprint_click(byval sender as object, byval e as system.eventargs) handles btnprint.click<br />
printing()<br />
End Sub
|
|
|
|
|
hi,
can any one help me in accessing the word document and modify some content in the word document through vb
|
|
|
|
|
|
hi deepak,
it was a good link . but i not able to see the code .please give me some other links or details
|
|
|
|
|
Hello guys,
Can anyone provide me with a source code to open and read a data from an excel file and then write it in a another excel file. Thanx in advance!!
|
|
|
|
|
You can control Excel using the Microsoft Office Toolkit, or you can read/write csv files, which Excel can read/write
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
|
Hello
I started to edit my old vb.net - windows program. I could not cut,copy,paste,delete anything ( button, panel, label) on windows form. I can add for example a new button but can not delete it ?? If I start a new project everything works. How to get my old project editable again? I use Vb.net 2003 std.
|
|
|
|
|
Is the file read only ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
No. File is editable like all project files.
|
|
|
|
|
I try to learn simple network programming by using vb.net that I got some problem. I don't know how to get the ipv6 address on my machine.
Please explain in details because I'm just a novice in prigramming.
Thankyou
|
|
|
|
|
' This program shows how to use the IPAddress class to obtain a server
' IP addressess and related information.
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Text.RegularExpressions
Imports Microsoft.VisualBasic
Namespace Mssc.Services.ConnectionManagement
Module M_TestIPAddress
Class TestIPAddress
'The IPAddresses method obtains the selected server IP address information.
'It then displays the type of address family supported by the server and
'its IP address in standard and byte format.
Private Shared Sub IPAddresses(ByVal server As String)
Try
Dim ASCII As New System.Text.ASCIIEncoding()
' Get server related information.
Dim heserver As IPHostEntry = Dns.Resolve(server)
' Loop on the AddressList
Dim curAdd As IPAddress
For Each curAdd In heserver.AddressList
' Display the type of address family supported by the server. If the
' server is IPv6-enabled this value is: InternNetworkV6. If the server
' is also IPv4-enabled there will be an additional value of InterNetwork.
Console.WriteLine(("AddressFamily: " + curAdd.AddressFamily.ToString()))
' Display the ScopeId property in case of IPV6 addresses.
If curAdd.AddressFamily.ToString() = ProtocolFamily.InterNetworkV6.ToString() Then
Console.WriteLine(("Scope Id: " + curAdd.ScopeId.ToString()))
End If
' Display the server IP address in the standard format. In
' IPv4 the format will be dotted-quad notation, in IPv6 it will be
' in in colon-hexadecimal notation.
Console.WriteLine(("Address: " + curAdd.ToString()))
' Display the server IP address in byte format.
Console.Write("AddressBytes: ")
Dim bytes As [Byte]() = curAdd.GetAddressBytes()
Dim i As Integer
For i = 0 To bytes.Length - 1
Console.Write(bytes(i))
Next i
Console.WriteLine(ControlChars.Cr + ControlChars.Lf)
Next curAdd
Catch e As Exception
Console.WriteLine(("[DoResolve] Exception: " + e.ToString()))
End Try
End Sub 'IPAddresses
' This IPAddressAdditionalInfo displays additional server address information.
Private Shared Sub IPAddressAdditionalInfo()
Try
' Display the flags that show if the server supports IPv4 or IPv6
' address schemas.
Console.WriteLine((ControlChars.Cr + ControlChars.Lf + "SupportsIPv4: " + Socket.SupportsIPv4.ToString()))
Console.WriteLine(("SupportsIPv6: " + Socket.SupportsIPv6.ToString()))
If Socket.SupportsIPv6 Then
' Display the server Any address. This IP address indicates that the server
' should listen for client activity on all network interfaces.
Console.WriteLine((ControlChars.Cr + ControlChars.Lf + "IPv6Any: " + IPAddress.IPv6Any.ToString()))
' Display the server loopback address.
Console.WriteLine(("IPv6Loopback: " + IPAddress.IPv6Loopback.ToString()))
' Used during autoconfiguration first phase.
Console.WriteLine(("IPv6None: " + IPAddress.IPv6None.ToString()))
Console.WriteLine(("IsLoopback(IPv6Loopback): " + IPAddress.IsLoopback(IPAddress.IPv6Loopback).ToString()))
End If
Console.WriteLine(("IsLoopback(Loopback): " + IPAddress.IsLoopback(IPAddress.Loopback).ToString()))
Catch e As Exception
Console.WriteLine(("[IPAddresses] Exception: " + e.ToString()))
End Try
End Sub 'IPAddressAdditionalInfo
Public Shared Sub Main(ByVal args() As String)
Dim server As String = Nothing
' Define a regular expression to parse user's input.
' This is a security check. It allows only
' alphanumeric input string between 2 to 40 character long.
'Define a regular expression to parse user's input.
'This is a security check. It allows only
'alphanumeric input string between 2 to 40 character long.
Dim rex As New Regex("^[a-zA-Z]\w{1,39}$")
If args.Length < 1 Then
' If no server name is passed as an argument to this program, use the current
' server name as default.
server = Dns.GetHostName()
Console.WriteLine(("Using current host: " + server))
Else
server = args(0)
If Not rex.Match(server).Success Then
Console.WriteLine("Input string format not allowed.")
Return
End If
End If
' Get the list of the addresses associated with the requested server.
IPAddresses(server)
' Get additonal address information.
IPAddressAdditionalInfo()
End Sub 'Main
End Class 'TestIPAddress
End Module
End Namespace
Nothing is Impossible in Life Need Is Try for It
Think Big Get Big
Don’t Forget To Rank Best Post
|
|
|
|
|
Thnakyou
|
|
|
|
|
Hi Folks,
Can any one tell me how to sort a column in datagrid?????I have done the sorting which works fine when we click the headertext in ascending and descending accordingly.
Now i need the same functionality when i click the up and down arraows placed side of the header text.....is it possible to place images beside hearder text???
Thanks
Vin1070
|
|
|
|
|
Hi,
i have datagridview in my vb.net(winforms) application,
& have combox in every cell of a column of Customer's name
How to Access Current Index Of Combobox which is in Datagridview??
priya
|
|
|
|
|
Hi Priya,
You can get current index from ComboBox1.SelectedIndex .
|
|
|
|
|
thnx for help
yes i know it, but my datagridview columntype as combobox so how to access curr index property of that datagridview cell of type combobox.
Please help me
priya
|
|
|
|
|
priya,
can u copy and paste the piece of code which u r using or e-mail me??
|
|
|
|
|
hi ,
i wrote following code -->
MyCommand.CommandType = CommandType.Text
MyCommand.CommandText = "SELECT CustName FROM cust_mast;"
MyCommand.Connection = conn
MyDataAdapter.SelectCommand = MyCommand
MyDataAdapter.Fill(dt)
''---------------------------------
DGTimeSheet.AutoGenerateColumns = False
CombCust = New DataGridViewComboBoxColumn
With CombCust
.DataSource = dt
.DataPropertyName = "Custname"
.ValueMember = "Custname"
.DisplayMember = "Custname"
.HeaderText = "Custname"
.DropDownWidth = 200
.Width = 90
.MaxDropDownItems = 3
.FlatStyle = FlatStyle.Flat
End With
DGTimeSheet.Columns.Insert(0, CombCust)
DGTimeSheet.Columns(0).Width = 235
''-----------------------------------------------------
now wht i wnt is->
i wnt to take one more combobox which is filled with customerID & at runtime when we select item in datagridview's Customer comboColumn , it should set current index of that other customerID
comboBox same as datagridview's customer comboBox column.
(coz i have to fill next combocolumn, depending on which customer, i have selected in that row.& as custid is primary key, i require related customerID of selected customer)
As it is possible for our normal comboboxes by writing code-->
Private Sub cmbcust_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmbcust.SelectedIndexChanged
cmbCustId.SelectedIndex = cmbcust.SelectedIndex
End Sub
d
but i didnt get the current index of a combobox that is in datagridview
Will u please tell how shuld i do it.
--Regards Priya
priya
|
|
|
|