|
if you want to pass data between forms , you can add owned forms, eg:
in Form1:
Dim frm As New Form2<br />
Me.AddOwnedForm(frm)<br />
frm.Show()
in Form2:
Dim frmMain As Form1 = Me.Owner<br />
frmMain.TextBox1.Text = "something from Form2, passed to Form1!"
|
|
|
|
|
I have a problem, I need to set the size of a button in VB6 to 75 pixels and 23 pixels tall. However, the button has a height and width property, but these numbers are a lot larger than 75. Eg, if i set the button to width 75, it would barely be visible, as the default ones are about a width of 1475. Can you please help me with this
|
|
|
|
|
the default units are twips not pixels
if you want to use pixels set the Form's Scalemode property to Pixels..
then set Width, height for the button to 75 , 23
|
|
|
|
|
The following works if only one row & one column is returned in a function
Dim ssql As String
ssql = "select full_name from EMPLOYEE WHERE full_name = '" & usertoLookup & "'"
Dim myCommand As New OleDb.OleDbCommand(ssql, OleDbConnection1)
OleDbConnection1.Open()
EngActivitiesToFind = myCommand.ExecuteScalar()
myCommand.Dispose()
OleDbConnection1.Close()
The following works if dataset / dataview returns multiple rows to bind to datagrid in a function
Dim myCommand As New OleDb.OleDbCommand(strsql, myConnection)
Dim MyAdapter As New OleDb.OleDbDataAdapter(myCommand)
myConnection.Open()
MyActivityDataSet.Clear()
MyAdapter.Fill(MyActivityDataSet, "dcr_track")
EngActivityDataView.Table.Clear()
DataGrid_DCR.Refresh()
EngActivityDataView = MyActivityDataSet.Tables("dcr_track").DefaultView
DataGrid_DCR.DataSource = EngActivityDataView
But how do you handle it in a single function if sometimes your retrieve returns multiple rows and other times a single row dependent on a query that is dynamic and dependent on user input
Thanks
Milancie
|
|
|
|
|
Use the "ExecuteReader" function to obtain a rataReader object. Then you can read the rows one at a time.
Alternatively, you can instantiate a DataSet and "fill" it with your connection and then access the data in the dataset as you would any other database, or use it to fill your datagrid.
There are actually lots of choices and I'm not sure which best fits your situation
pxw
|
|
|
|
|
how can i access to inbox in outlook..
I have outlook 9.0 reference..in VB .NET
I have create new folder call Temp to recieve and send email from my hotmail account...
When I click InBox.. there were lots of mails inside.. and I want to access each message programmatically.. and I dont' really know how to do it..
I tried something like following..
Dim olApp As Outlook.Application<br />
olApp = new Outlook.Application<br />
Dim fldMain As Outlook.Folders<br />
fldMain = gnspNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox)<br />
<br />
thatnks
|
|
|
|
|
|
I have following code, but folder.items is not a collection object so it gives me error. I'm using VB .Net not VB 6.0
<br />
Dim olApp As Outlook.Application<br />
olApp = New Outlook.Application<br />
<br />
Dim mail As Outlook.MailItem<br />
Dim nSpace As Outlook.NameSpace<br />
Dim folder As Outlook.MAPIFolder<br />
Dim eInfo As emailInformation<br />
<br />
nSpace = olApp.GetNamespace("MAPI")<br />
folder = nSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox)<br />
<br />
For Each mail In <font color = green>folder.Items</font><br />
eInfo.theBody = mail.Body()<br />
eInfo.theCC = mail.CC<br />
eInfo.theFrom = mail.SenderName<br />
eInfo.theTo = mail.ReceivedByName<br />
eInfo.theDate = "12/13/4"<br />
eInfo.theSubject = mail.Subject<br />
eInfo.wayToPrint = 1<br />
PrintEmail(eInfo)<br />
Next<br />
<br />
|
|
|
|
|
Opps! My bad! Following the docs for MAPIFolder and MailItems you must use the built in Iterator Methods of the MAPIFolder. These of GetFirst(), GetNext(), GetLast(), and GetPrevious().
Dim olApp As New Outlook.Application
Dim mailItem As Outlook.MailItem
Dim nSpace As Outlook.NameSpace
Dim ibFolder As Outlook.MAPIFolder
nSpace = olApp.GetNamespace("MAPI")
ibFolder = nSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox)
Debug.WriteLine("Number of messages in folder " & ibFolder.Name & ": " & ibFolder.Items.Count)
mailItem = ibFolder.Items.GetFirst()
While (Not mailItem Is Nothing)
Debug.WriteLine("Message Header: " & mailItem.Subject)
mailItem = ibFolder.Items.GetNext()
End While
Microsoft didn't do the greatest job in the world with the documentation on the Office Object Models...
RageInTheMachine9532
|
|
|
|
|
thank you very much RageIn...
|
|
|
|
|
Hi..
I have the following code
<br />
Dim ie As New SHDocVw.InternetExplorer<br />
ie = CreateObject("InternetExplorer.Application")<br />
<br />
With ie<br />
.Visible = False<br />
.Navigate("c:\OutLookStyle.html")<br />
.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER) 'printing the file without showing the print dialog<br />
System.Threading.Thread.Sleep(5000) 'pausing the application to finish printing<br />
End With<br />
ie.Quit()
But i'm getting the following error whenever the project execute
.ExecWB(....)
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in emailPrint.exe
Additional information: Trying to revoke a drop target that has not been registered
(OR)
An error has occurred in the script o this page
Line: 288
Char: 1
Error: 'dialogArguments.__IE_PrintType' is null or not an object
Code: 0
URL: res://c:\\windows\system32\shdoclc.dll/priview.dlg
Do you want to continue running scripts on this page? Yes/No?
But I have no problem or whatsoever, if I debug and put a breakline on .ExecWB(..). the html page get printed without showing printdialog as I excepted. If I dont have a breakline at .ExecWB(..) then I got either or both of above errors( in red )
what would be the reason of getting such errors? and How can i print the web page to printer without showing PrintDialog???
|
|
|
|
|
Hi,
how do i print to the printer from right to left with vb.net
example in vb6:
Printer.RightToLeft = True
Printer.Print "abcd"
Printer.EndDoc
please send me small example
thanking you in advance
From:
yulyos@yahoo.com
http://www.go.to/yulyos
|
|
|
|
|
In Visual Basic 6.0, the Printer object was used for printing; it supported various graphics methods such as Print, Line, and PaintPicture to control what was printed.
In Visual Basic .NET, the PrintDocument component replaces the Printer object. Equivalent graphics methods include the DrawString, DrawLine, and DrawImage methods of the Graphics class.
Imports System.Drawing.Printing
Dim printer As New PrintDocument
printer.Print()
|
|
|
|
|
Hi,
every word you wrote it's right.
but where is the answer about:
how do i print to the printer from right to left with vb.net
thanking you in advance
From:
yulyos@yahoo.com
http://www.go.to/yulyos
|
|
|
|
|
|
RightToLeft No longer necessary. The direction of printing is controlled by the localization settings in Windows.
Yes I know, but it is not working
From:
yulyos@yahoo.com
http://www.go.to/yulyos
|
|
|
|
|
I see.. let me see it then..
|
|
|
|
|
Hi all....
I am working on a VB.net application at attaches to a database in disconnected mode. I am haveing trouble retreving an autonumber field. Here is the code as I have it now:
Dim drw1 As DataRow = das3.Tables("tomdb").NewRow()
drw1("Name") = TextBox3.Text
drw1("function") = TextBox4.Text
If RadioButton1.Checked Then
drw1("accesslevel") = "1"
ElseIf RadioButton2.Checked Then
drw1("accesslevel") = "2"
ElseIf RadioButton3.Checked Then
drw1("accesslevel") = "3"
Else
drw1("accesslevel") = "3"
End If
drw1("UserID") = Integer.MaxValue
das3.Tables("tomDB").Rows.Add(drw1)
AddHandler dap3.RowUpdated, New OleDb.OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated)
--------------------------------------------------------------------------------------
Private Sub OnRowUpdated(ByVal sender As Object, ByVal args As OleDb.OleDbRowUpdatedEventArgs)
Dim int1 As Integer = 0
Dim cmd1 As OleDb.OleDbCommand = New OleDb.OleDbCommand("SELECT @@IDENTITY", cnn3)
If args.StatementType = StatementType.Insert Then
int1 = CInt(cmd1.ExecuteScalar())
args.Row("UserID") = int1
End If
End Sub
--------------------------------------------------------------------------------------
In my code it should retreve the next record number but all I get is a 0.
Any ideas?
Gonz
|
|
|
|
|
This is a text app I whiped up. The Button1_Click works and Button2_Click does not.
You have to get the value before the connection is closed.
<br />
Private m_connection As OleDb.OleDbConnection <br />
<br />
Private m_connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source="<br />
<br />
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)<br />
MyBase.OnLoad( e )<br />
m_connectionString &= HunterDev.Environment.GetUserFolderPath( SpecialFolders.Personal ) & "\db1.mdb"<br />
End Sub<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
If ( m_connection Is Nothing ) Then<br />
m_connection = New OleDb.OleDbConnection( m_connectionString )<br />
End If<br />
Dim command As New OleDb.OleDbCommand( "INSERT INTO Sample ( Name ) VALUES ( '" & TextBox1.Text & "' )", m_connection )<br />
Dim idCommand As New OleDb.OleDbCommand( "SELECT @@IDENTITY", m_connection )<br />
If ( m_connection.State <> ConnectionState.Open ) Then<br />
m_connection.Open()<br />
End If<br />
command.ExecuteNonQuery()<br />
Dim id As Integer = CInt( idCommand.ExecuteScalar() )<br />
If ( m_connection.State <> ConnectionState.Closed ) Then<br />
m_connection.Close()<br />
End If<br />
TextBox2.AppendText( id.ToString() & vbCrLf )<br />
End Sub<br />
<br />
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click<br />
Dim idCommand As New OleDb.OleDbCommand( "SELECT @@IDENTITY", m_connection )<br />
If ( m_connection.State <> ConnectionState.Open ) Then<br />
m_connection.Open()<br />
End If<br />
Dim id As Integer = CInt( idCommand.ExecuteScalar() )<br />
If ( m_connection.State <> ConnectionState.Closed ) Then<br />
m_connection.Close()<br />
End If<br />
TextBox2.AppendText( id.ToString() & vbCrLf )<br />
End Sub<br />
Bo Hunter
|
|
|
|
|
Hi,
We are trying to auto compress files through the command prompt. The problem is the file we would like to compress changes every 15 minutes as it is archived using DTS making it hard to code a specific file name, and we dont want to zip them all up incase the zip file becomes corrupt then we loose them all.
We purchased WINRAR command prompt, and need to find a way to write a script, or something that will read the contents of a directory, and give us the most current file that was saved.
Has anyone done this, and if so is there code that would be usable somewhere..??
Thanks,
-David
|
|
|
|
|
Look up the FileSystemObjct on MSDN, or if you fancy doing it by the seat of your pants so to speak, just set a project reference to WindowsScriptingHost (??? - Dunno).
With the reference set, something like
set oMyFSO = new WindowsScriptHost.FileSystemObject
Should allow you to access all sorts of objects and methods for dealing with the filesystem (F2 = Object browser which will prob help!)
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Why does this not work?
Dim appword As Object
Public Sub start()
Set appword = CreateObject("Word.Application")
If appword Is Nothing Then
MsgBox "appword = Nothing"
Else
appword.Visible = 1
End If
MsgBox "Test"
MsgBox "Test2"
End Sub
---
appword is allways nothing, CreateObject does not work...
Is there any hidden security setting in Office 2000 I dont
know?
bb |~ bb
|
|
|
|
|
Dim appword As Object
should come after Public Sub start()
|
|
|
|
|
NOt necessarily - could be a member variable of his form, and not just a local - maybe it needs to be used by other functions / subs
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Did you add a reference to Word10 ? Then you can just declare it like so:
Dim appWord as Word.Application
Set appWord = New Word.Application
Nick Seng (the programmer formerly known as Notorious SMC)
God, I pity me! - Phoncible P. Bone
|
|
|
|