|
No it's not. You must Dim the variable first, otherwise VB will not know how to pass the variable to the function. Also, If your going to return values in the variable you pass in the function parameters, you must pass it ByRef, not ByVal.
Dim inputArray As String()
MyFunction(inputArray)
.
.
.
Public Sub MyFunction(ByRef ia As String())
ReDim ia(someNumber)
End Sub
Or, you could do it as a return value from a Function:
Dim inputArray As String()
inputArray = MyFunction(someValue)
.
.
.
Public Function MyFunction(ByVal value) As String()
Dim ia As String()
Return ia
End Sub
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
As said in the other post, you probably want to pass the parameter by Ref or return a value.
However it is possible to call a function or sub with the array declaration inline, as it were.
MyFunction(New Object() {Object1, Object2, Object3})
Another method that I prefer is to use a ParamArray as the parameter. This would give the following.
Public Sub MyMethod(ByVal ParamArray args() As Object)
' Do Stuff
End Sub
...
MyMethod(Object1, Object2, Object3)
Using this style you can pass the elements of the array as if they were parameters, and it still acts like an array.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
|
|
|
|
|
Is there a way that one can call a web service asynchonously (from a windows application, for example), be able to continue processing user input whilst waiting for the web service response, and be able to specify a timeout? I have previously used asyncCallBack, which allows an application to carry on working whilst waiting for the response from a web service, but it doesn't allow one to specify a timeout. One can use waitHandles, but I don't believe they offer that same flexibilty for the processing the application can carry out whilst it awaits a response. Any ideas?
|
|
|
|
|
|
Thanks, I'll have a look.
|
|
|
|
|
I Had an xml file that had a table in it.table0
I have recently added another. table1.
now when I run my program it says there are multiple root elements Line 10,position 2. does this mean i need to use SQL. if so or if not can someone type some sample code that would stop the root element problem. If you need to see my code I have another thread posted under datagrid/xmlfile that i posted yesterday and is on the next page.
|
|
|
|
|
The clue is in the error... i am guessing your original file was something like this:
<Table>
<FirstElement/>
<SecondElement/>
...
<LastElement/>
</Table>
Now i am guessing that you have a second table it looks something like this:
<Table>
<FirstElement/>
<SecondElement/>
...
<LastElement/>
</Table>
<Table>
<FirstElement/>
<SecondElement/>
...
<LastElement/>
</Table>
The problem is the two Table nodes in the root, therefore you need to put in a single root element:
<Tables>
<Table>
<FirstElement/>
<SecondElement/>
...
<LastElement/>
</Table>
<Table>
<FirstElement/>
<SecondElement/>
...
<LastElement/>
</Table>
</Tables>
Hope this helps
Tom
|
|
|
|
|
I want to prompt user for internet connection wizard if he is not connected.
how it can be done?
|
|
|
|
|
hi,
I have to develop a ftp client using VB.Net and infragistics control. I want to get sample code for this.
Your help in this regard will be greatly appreciated.
Thanks and regards.
Zubair.
|
|
|
|
|
Well, you haven't given us any details with what you need help with. If your just trying to find example code to modify and call your own, then Google for it -> Google results on "FTP Infragistics example"[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to capture the start time and the pause time of the video clip from the windows media player that we have designed in vb.net.
suppose the duration of the video file is 4 min 36 secs then by using
axmediaplayer.duration method we get the durations in seconds, which is greater than the time specified ,
I want to know how to capture when the time when the user has done the following operations on clip like
play ,
stop,
Pause
|
|
|
|
|
I think your looking for Player.Controls.currentPosition. But when the user clicks Stop, the position will be 0, no the position when Stop was clicked.
You can find the docs on the Media Player Objects here[^] on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How can I workaround for Type Mismatch 13 error?
Seemslike application crush when this error generated.
I want to avoid it.
Thanks in advance.
Shin
|
|
|
|
|
Can you post the code that is causing the error?
|
|
|
|
|
Without seeing the code that generated the error, there is nothing we can tell you. Type Mismatch can be generated by so many things it's impossible to determine what went wrong without seeing the code.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How do you add BMPs to a PopupMenu? I tried doing the same thing you do for standard menus and this does not work. Any ideas?
[code]
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, IpMenuItemInfo As MENUITEMINFO) As Boolean
Private Type MENUITEMINFO
cbSize As Long
fMask As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Private Const MIIM_ID = &H2
Private Const MIIM_TYPE = &H10
Private Const MFT_STRING = &H0&
Private Const MF_BITMAP = &H0&
Dim hMenu As Long, hSubMenu As Long, hID As Long
'Get the Menuhandle of the form
hMenu = GetMenu(frmMain.hwnd)
'Get the handle of the PopupMenu submenu
hSubMenu = GetSubMenu(hMenu, 0)
hID = GetMenuItemID(hSubMenu, 0)
SetMenuItemBitmaps hMenu, hID, MF_BITMAP, imgMenuItem(0).Picture, imgMenuItem(0).Picture
hID = GetMenuItemID(hSubMenu, 1)
SetMenuItemBitmaps hMenu, hID, MF_BITMAP, imgMenuItem(0).Picture, imgMenuItem(0).Picture
hID = GetMenuItemID(hSubMenu, 2)
SetMenuItemBitmaps hMenu, hID, MF_BITMAP, imgMenuItem(1).Picture, imgMenuItem(1).Picture
[/code]
Thanks,
Tim
|
|
|
|
|
TAlvord@kavlico.com wrote:
How do you add BMPs to a PopupMenu?
You could just inherit from the menuitem class, set the OwnerDraw = True and override the OnDrawItem method?
Public Class MyMenuItem
Inherits System.Windows.Forms.MenuItem
Private mImage As Image
Public Property Image() As Image
Get
Return mImage
End Get
Set(ByVal Value As Image)
mImage = Value
End Set
End Property
Public Sub New()
MyBase.new()
Me.OwnerDraw = True
End Sub
Protected Overrides Sub OnDrawItem(ByVal e As DrawItemEventArgs)
'Draw image and text here
MyBase.OnDrawItem(e)
End Sub
End Class Hope this helps
Tom
|
|
|
|
|
I am new to visual basic and VB.NET. Currently, I am creating a small program that involves switching between forms. I have two forms; the first form is named frmMainScreen and the second form is labled frmDeposit. By clicking a command button on the frmMainScreen form, I want to switch from frmMainScreen to frmDeposit. Does anyone have any idea on how to do this? Thanks
|
|
|
|
|
Ryan Coleman wrote:
I am creating a small program that involves switching between forms
Try this code in your click event button:
Dim frm2nd as frmDeposit<br />
<br />
frm2nd.ShowDialog()
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hi Ryan,
You should be able to do this as follows...
Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim frm As New frmDeposit
frm.Show()
End Sub
|
|
|
|
|
It worked. Thanks for the help.
|
|
|
|
|
hello guys
i'm on a network, right, so that my application always ask queries to the server. Sometimes connection failed.
i'd like to write a module that allow me to check/test if connection is correct.
i'm using the ADODB.CONNECTION in VB6. i don't know if there's a better way to do it in vb6, so help me to do so, please.
see you.
Sincerely yours.
marc
|
|
|
|
|
This may help.
Set up your Connection in a module and set your connection object as public eg
Public cn As ADODB.Connection.
In a form set up another object to handle the connection object events (adodb objects provide events that you can use but it is not as simple as other objects)eg
Dim WithEvents cnevent As ADODB.Connection
at the form open event use the following to set the event raising object to your connection object:
Set cnevent = cn
Now you will find you have access to several connection events such as WillConnect, ConnectComplete and Disconnect.
If the form you do this in is an MDI parent then connection events in all child forms will be triggered in this form. You can also do the same for ADO recordset objects aswell.
Jon
|
|
|
|
|
I have an app running on an internal server using the following code:
Imports System.Web.Mail
Private Sub EmailError(Optional ByVal sError As String = "Default")
Try
TextBox1.Text += "Emailing Error now." & vbCrLf
TextBox1.Refresh()
Dim oMail As New MailMessage
oMail.To = m_sErrorEmail
oMail.From = "User1@xxxxx.org"
oMail.Subject = "Error Occured in Profile Scoring"
oMail.BodyFormat = MailFormat.Html
oMail.Body = sError
'SmtpMail.SmtpServer.Insert(0, "127.0.0.1")
SmtpMail.Send(oMail)
TextBox1.Text += "Email sent." & vbCrLf
TextBox1.Refresh()
Catch ex As Exception
TextBox1.Text += "Error occurred in EmailError." & vbCrLf
TextBox1.Text += "Stopping process." & vbCrLf
TextBox1.Refresh()
EmailError(ex.ToString())
btnEnd.PerformClick()
End Try
End Sub
The email goes out no problem as long as the To address is outside of the xxxxx.org domain. However, if trying to send to an internal email address (i.e. User2@xxxxx.org) then the email does not arrive. BTW both email accounts are valid in Active Directory.
Any thoughts? This is super simple code. Would love to know what I am doing wrong. I recognize that it may be an exchange or domain security issue but I need some direction. Thanks for your help.
CitizenSoldier
|
|
|
|
|
My VB application is accessing quite a few files, tables, select OCBC queries etc. I've painstakingly checked each and every one to make sure they are closed and set to NOTHING once I've done processing them. I need to add indexes to my tables at the very end of the app.
I've come accross "BackgroundFetch" as a refresh option, because even though the files are closed the app (or maybe my OS) is not seeing them as closed. "BackgroundFetch=No" or "BackgroundFetch=Yes"? Neither fail or cause errors when added to the connection strings. But neither stop the database error either.
Currently I've taken the easy way out and just made the app sleep for a minute before adding the indexes. Does anyone know if I'm using "BackgroundFetch" correctly? Is there another option to force a refresh on these tables that are already closed?
Aubrey
|
|
|
|