|
Re:OpenFileDialog
What s the problem in using as follows
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
If Not Me.OpenFileDialog1.FileName.ToLower.EndsWith("abc.vb") Then
MessageBox.Show("You cannot open this file")
e.Cancel = True
End If
End Sub
|
|
|
|
|
mythinky wrote:
2. How to get the startup directory of the windows service? I have used the Environment.Directory, it doesn't work. It will return C:\Windows\System32\.
Try Application.ExecutablePath . This will give you the complete path to the .EXE that started your app. Just remove the filename from the end of what's returned.
Imports System.IO
.
.
.
Dim path As String
path = Application.ExecutablePath()
path = path.SubString(1, path.LastIndexOf(Path.DirectorySeparatorChar))
This should return the complete path to the executable (not including the filename) appended with the path seperator character ( \ ).
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am trying to develop a simple Hello world program for PocketPC when i test it in PocketPC Emulator it works just fine but when i try tu Run it on my PocketPC - the real one, it fails!
Am I doing something wrong is there anything that I should know?????
soni_xiao
|
|
|
|
|
This question really belongs in the Embedded/Mobil Forum.
But, did you install the .NET Compact Framework (same version as your dev environment) on the Pocket PC?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I think that when I press run (F5) in visual studio dev env it automatically deploys .net CF to PocketPC. at least it does so in emulator.
Thanks anyway
|
|
|
|
|
Hi. I am working on a project which involves one server and many remote apps accessing its features.(A cyber classroom). I have a problem that when i receive a picture from the sever through remoting, i am unable to display it due to some serialization problem. Secondly i am stuck in remoting events. I want a remote event which is broadcasted to all subscribers when fired. If someone could help me, i would be greatley thankful.
|
|
|
|
|
Hi
If you are using the winsock activex control then you need to build some optimizations around your server and client apps. You will find that if you use the SendData sub routine you will have to send data in packets each around 512 to 2048 bits in size and also delay the packets until the SendComplete() event is called each time.
};
|
|
|
|
|
anybody know how to call a form using keyboard key like F3.
and also how to pass a value from a form to a textbox of other form in vb.net.
|
|
|
|
|
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown<br />
If e.KeyCode = Keys.F3 Then<br />
Dim f As New Form2<br />
f.Show()<br />
e.Handled = True<br />
End If<br />
End Sub
Here Form1 is a form having the KeyDown EventHandler and Form2 is just another form.
This code will not work if your Form1 has controls like Textbox and the TextBox control has focus, because the default value of the KeyPreview of Form is False. In order to make working of F3 even the TextBox has focus, You have to set the KeyPreview property to True.
I think this will solve your problem.
|
|
|
|
|
The following will demonstrate passing a value from one form to another.
I have Form1 class with KeyPreview property set to True and class variable of type Form2 which has a TextBox and a Public Property to get or set the TextBox Text. The Form1 class has three EventHandler which will be helpful for getting the Form2 class TextBox Text.
Add the following to the Form1.
Private f As Form2
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
f = New Form2
AddHandler f.Closing, AddressOf SetTextBox
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.F3 Then
f.Show()
e.Handled = True
End If
End Sub
Private Sub SetTextBox(ByVal sender As Object, ByVal e As CancelEventArgs)
If f.TextBoxText.Trim.Length < 1 Then
MessageBox.Show("Type some text in TextBox")
Else
Me.TextBox1.Text = f.TextBoxText
f.TextBoxText = ""
f.Hide()
End If
e.Cancel = True
End Sub
Add the following to the Form2
Public Property TextBoxText() As String
Get
Return Me.TextBox1.Text
End Get
Set(ByVal Value As String)
Me.TextBox1.Text = Value
End Set
End Property
In the Form1 pressing F3 will open the Form2 and when Form2 is closed the TextBox text of Form2 will be set to Form1 TextBox.
I hope this will do.
|
|
|
|
|
I am trying to get word document title and number of word in the document
Currently, I can only get these properties from opening the document.
Is there any way to get these information without actually opening the word
document.
Shin
|
|
|
|
|
No, there isn't. You have to open the document. From what I can see in the file format, those properties are not stored in the file.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thank you for your input,
This is the way to get the document property
Is there any way to open the word document silently?
The source code below is not working.
wordApp.Documents.Open strFileName
wordApp.Visible = False
VB6/Windows2000
Shin
|
|
|
|
|
I found a solution. the dll dsofile.dll
was availble for getting office document
properties with out open. I downloaded and
used from kb. Thank you.
Shin
"Microsoft Knowledge Base Article - 224351 "
Dim oFilePropReader As DSOleFile.PropertyReader
Dim oDocProp As DSOleFile.DocumentProperties
Set oFilePropReader = New DSOleFile.PropertyReader
Set oDocProp = oFilePropReader.GetDocumentProperties(strFileName)
Debug.print oDocProp.Title
'display the title of document
set oFilePropReader = nothing
|
|
|
|
|
how to display a word file as another application on a button click event
www
|
|
|
|
|
Use the Process and ProcessStartInfo classes in your button Click event handler to launch the .DOC file:
Dim procStartInfo As New ProcessStartInfo(fullPathToWordDOCFile)
procStartInfo.UseShellExecute = True
Process.Start(procStartInfo)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi, I'm a vb6 programmer. I prefer to use vb6 to connect to the database. I like to use DAO when connec to the database in Ms Access. But I need some people help me to do the following thing:
1. Give me a sample code with step by step explaination on using ADO to connect to the database without using using ADO data control.
2. Give me a sample code with step by step explaination on using VB.NET and ADO.NET to connect to the database without using using SqlDataAdapter, OleDbDataAdapter and the other control.
Note: If you can explain each function of these control (such as OleDbDataAdapter, OleDbConnection, OleDbCommand...) and the procedue to use it, it would be better.
Sometime I read from the books in the section of database system but it seem that the books is not explain too much clear.
Please help me!!!
Roath Kanel
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hi,
I'm trying to build a little service that can read mail from my pop3 server and inject then to my exchange server.
I've found a little DLL that can read pop3 mail but I need to rebuild all the message and resend it after via SMTP.
My question, is there already some DLL that can be used to send mail to exchange directly and to retrieve the pop3 mail directly in a good format
Thx
Sybux
|
|
|
|
|
Hi,
Can anyone tell me is this possible.....
I want to fill the DataGrid. I have 5 columns selected in the Query using Joins from 2 Tables.
I want to Fill the Datas in the Grid along with it, add 2 more columns to be added in the Grid, but the 2 added columns should be used as Date Picker.
This is for VB.NET application. and it is a Very urgent task to Complete.
pls help me out in doing this Task.
(Note: I'm NEW to .NET)
Thanx and Regards,
Tthangaraj P.V.
tthangarajpv@yahoo.com
|
|
|
|
|
Hi,
There is a great sample for doing this in MSDN. I am just giving it.
Imports System<br />
Imports System.Data<br />
Imports System.Windows.Forms<br />
Imports System.Drawing<br />
Imports System.ComponentModel<br />
<br />
' This example shows how to create your own column style that<br />
' hosts a control, in this case, a DateTimePicker.<br />
Public Class DataGridTimePickerColumn<br />
Inherits DataGridColumnStyle<br />
Private timePicker As New DateTimePicker()<br />
' The isEditing field tracks whether or not the user is<br />
' editing data with the hosted control.<br />
Private isEditing As Boolean<br />
<br />
Public Sub New()<br />
timePicker.Visible = False<br />
End Sub<br />
<br />
Protected Overrides Sub Abort(ByVal rowNum As Integer)<br />
isEditing = False<br />
RemoveHandler timePicker.ValueChanged, _<br />
AddressOf TimePickerValueChanged<br />
Invalidate()<br />
End Sub<br />
<br />
Protected Overrides Function Commit _<br />
(ByVal dataSource As CurrencyManager, ByVal rowNum As Integer) _<br />
As Boolean<br />
timePicker.Bounds = Rectangle.Empty<br />
<br />
AddHandler timePicker.ValueChanged, _<br />
AddressOf TimePickerValueChanged<br />
<br />
If Not isEditing Then<br />
Return True<br />
End If<br />
isEditing = False<br />
<br />
Try<br />
Dim value As DateTime = timePicker.Value<br />
SetColumnValueAtRow(dataSource, rowNum, value)<br />
Catch<br />
End Try<br />
<br />
Invalidate()<br />
Return True<br />
End Function<br />
<br />
Protected Overloads Overrides Sub Edit( _<br />
ByVal [source] As CurrencyManager, _<br />
ByVal rowNum As Integer, _<br />
ByVal bounds As Rectangle, _<br />
ByVal [readOnly] As Boolean, _<br />
ByVal instantText As String, _<br />
ByVal cellIsVisible As Boolean)<br />
Dim value As DateTime = _<br />
CType(GetColumnValueAtRow([source], rowNum), DateTime)<br />
If cellIsVisible Then<br />
timePicker.Bounds = New Rectangle _<br />
(bounds.X + 2, bounds.Y + 2, bounds.Width - 4, _<br />
bounds.Height - 4)<br />
<br />
timePicker.Value = value<br />
timePicker.Visible = True<br />
AddHandler timePicker.ValueChanged, _<br />
AddressOf TimePickerValueChanged<br />
Else<br />
timePicker.Value = value<br />
timePicker.Visible = False<br />
End If<br />
<br />
If timePicker.Visible Then<br />
DataGridTableStyle.DataGrid.Invalidate(bounds)<br />
End If<br />
End Sub<br />
<br />
Protected Overrides Function GetPreferredSize( _<br />
ByVal g As Graphics, _<br />
ByVal value As Object) As Size<br />
Return New Size(100, timePicker.PreferredHeight + 4)<br />
End Function<br />
<br />
Protected Overrides Function GetMinimumHeight() As Integer<br />
Return timePicker.PreferredHeight + 4<br />
End Function<br />
<br />
<br />
Protected Overrides Function GetPreferredHeight(ByVal g As Graphics, ByVal value As Object) As Integer<br />
Return timePicker.PreferredHeight + 4<br />
End Function<br />
<br />
<br />
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer)<br />
Paint(g, bounds, [source], rowNum, False)<br />
End Sub<br />
<br />
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer, ByVal alignToRight As Boolean)<br />
Paint(g, bounds, [source], rowNum, Brushes.Red, Brushes.Blue, alignToRight)<br />
End Sub<br />
<br />
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean)<br />
Dim [date] As DateTime = CType(GetColumnValueAtRow([source], rowNum), DateTime)<br />
Dim rect As Rectangle = bounds<br />
g.FillRectangle(backBrush, rect)<br />
rect.Offset(0, 2)<br />
rect.Height -= 2<br />
g.DrawString([date].ToString("d"), Me.DataGridTableStyle.DataGrid.Font, foreBrush, RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))<br />
End Sub<br />
<br />
Protected Overrides Sub SetDataGridInColumn(ByVal value As DataGrid)<br />
MyBase.SetDataGridInColumn(value)<br />
If Not (timePicker.Parent Is Nothing) Then<br />
timePicker.Parent.Controls.Remove(timePicker)<br />
End If<br />
If Not (value Is Nothing) Then<br />
value.Controls.Add(timePicker)<br />
End If<br />
End Sub<br />
<br />
Private Sub TimePickerValueChanged(ByVal sender As Object, ByVal e As EventArgs)<br />
Me.isEditing = True<br />
MyBase.ColumnStartedEditing(timePicker)<br />
End Sub<br />
End Class<br />
<br />
Namespace DataGridColumnStyleExample<br />
Public Class MyForm<br />
Inherits Form<br />
<br />
Private namesDataTable As dataTable<br />
Private myGrid As DataGrid = New DataGrid()<br />
Public Sub New()<br />
<br />
InitForm()<br />
<br />
namesDataTable = New DataTable("NamesTable")<br />
namesDataTable.Columns.Add(New DataColumn("Name"))<br />
Dim dateColumn As DataColumn = _<br />
New DataColumn("Date", GetType(DateTime))<br />
namesDataTable.Columns.Add(dateColumn)<br />
Dim namesDataSet As DataSet = New DataSet()<br />
namesDataSet.Tables.Add(namesDataTable)<br />
myGrid.DataSource = namesDataSet<br />
myGrid.DataMember = "NamesTable"<br />
AddGridStyle()<br />
AddData()<br />
End Sub<br />
<br />
Private Sub AddGridStyle()<br />
Dim myGridStyle As DataGridTableStyle = _<br />
New DataGridTableStyle()<br />
myGridStyle.MappingName = "NamesTable"<br />
<br />
Dim nameColumnStyle As DataGridTextBoxColumn = _<br />
New DataGridTextBoxColumn()<br />
nameColumnStyle.MappingName = "Name"<br />
nameColumnStyle.HeaderText = "Name"<br />
myGridStyle.GridColumnStyles.Add(nameColumnStyle)<br />
<br />
Dim timePickerColumnStyle As DataGridTimePickerColumn = _<br />
New DataGridTimePickerColumn()<br />
timePickerColumnStyle.MappingName = "Date"<br />
timePickerColumnStyle.HeaderText = "Date"<br />
timePickerColumnStyle.Width = 100<br />
myGridStyle.GridColumnStyles.Add(timePickerColumnStyle)<br />
<br />
myGrid.TableStyles.Add(myGridStyle)<br />
End Sub<br />
<br />
Private Sub AddData()<br />
Dim dRow As DataRow = namesDataTable.NewRow()<br />
dRow("Name") = "Name 1"<br />
dRow("Date") = New DateTime(2001, 12, 1)<br />
namesDataTable.Rows.Add(dRow)<br />
<br />
dRow = namesDataTable.NewRow()<br />
dRow("Name") = "Name 2"<br />
dRow("Date") = New DateTime(2001, 12, 4)<br />
namesDataTable.Rows.Add(dRow)<br />
<br />
dRow = namesDataTable.NewRow()<br />
dRow("Name") = "Name 3"<br />
dRow("Date") = New DateTime(2001, 12, 29)<br />
namesDataTable.Rows.Add(dRow)<br />
<br />
dRow = namesDataTable.NewRow()<br />
dRow("Name") = "Name 4"<br />
dRow("Date") = New DateTime(2001, 12, 13)<br />
namesDataTable.Rows.Add(dRow)<br />
<br />
dRow = namesDataTable.NewRow()<br />
dRow("Name") = "Name 5"<br />
dRow("Date") = New DateTime(2001, 12, 21)<br />
namesDataTable.Rows.Add(dRow)<br />
<br />
namesDataTable.AcceptChanges()<br />
End Sub<br />
<br />
Private Sub InitForm()<br />
<br />
Me.Size = New Size(500, 500)<br />
myGrid.Size = New Size(350, 250)<br />
myGrid.TabStop = True<br />
myGrid.TabIndex = 1<br />
Me.StartPosition = FormStartPosition.CenterScreen<br />
Me.Controls.Add(myGrid)<br />
End Sub<br />
<br />
<STAThread()> _<br />
Public Shared Sub Main()<br />
Application.Run(New MyForm())<br />
End Sub<br />
End Class
|
|
|
|
|
|
Hi there -
i have to implement a remote control for clients. this control should be able to lock the client-workstation - in simple words: monitor black, keyboard and mouse locked.
I develope the program in VB.net and on the clients a service will run. and within this service, i want to call a function that does the things for me i just talked about.
but i have no idea what function (i think it is a win API function in GDI32) i have to use to do the locking. or has anyone a better idea?
i am open for all suggestions.
thanks a lot for all replies.
happy coding.
tom
|
|
|
|
|
There is no one function that will lock the keyboard and mouse. You have to write code to hook the keyboard and mouse and eat any messages that are sent your way from the keyboard and mouse drivers. Unfortunately, you can't keep the user from using Ctrl-Alt-Del. This key combination cannot be trapped. There is a great article on CodeProject by Michael Kennedy called "Global System Hooks in .NET"
[^] that demonstrats this technique.
Your service must also be set to "Allow interaction with Desktop" so that you can put up a form that covers the entire desktop area and tag that form as TopMost.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thank you very much for your hints.
the article seems to be what i was lookin' for ...
do you have an example how this thing with "allow interaction with desktop" works?
anyway- thanks for your help.
tom
|
|
|
|
|
Easy. When you instlal your service on the client, go into the Services control panel and find your service. Double-Click on it to bring up its properties and click on the LogOn tab. Make sure it is using the Local System Account and click on the Allow Service to interact with desktop checkbox. Click OK and your done.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|