Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Returning An Error


In A function or Subrotine, is it possible to return an error to what called it? That way I can use the On Error command more easily.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Returning Dictionary Gives Error
when i try to return dictionary by doing this "Return d
" return gets displayed red and says syntax err ...can someone tell me wats wrong


Dim d As Dictionary






Private Sub Form_Load()
Dim str(4, 2) As String
str(0, 0) = "abc"
str(0, 1) = "127.0.0.1"
str(1, 0) = "def"
str(1, 1) = "127.0.0.1"
str(2, 0) = "ghi"
str(2, 1) = "127.0.0.2"
str(3, 0) = "zzz"
str(3, 1) = "127.0.0.3"
str(4, 0) = "xxx"
str(4, 1) = "127.0.0.3"

Set d = New Dictionary
'd.Add "127.0.0.1", "ab"
'MsgBox d.Keys(0)
a1 = optimisearray(str())
End Sub
Function optimisearray(ByRef lngNum As Variant) As Dictionary


For i = 0 To UBound(lngNum, 1) - 1

If d.Exists(lngNum(i, 1)) Then

d.Item(lngNum(i, 1)) = d.Item(lngNum(i, 1)) & ":" & lngNum(i, 0)
Else
d.Add lngNum(i, 1), lngNum(i, 0)

End If




Next


'For Each v1 In d
'MsgBox v1
'MsgBox d.Item(v1)
'Next
Return d



End Function

VB Returning An Error When Writing The Exe
Hey,
While Writing The Executable The Following Error Is Generated

System Error &H800401F7(-2147221001) Some Error In Application Program

Why Do i Get This? And How Do I Solve This?

Is It Because Of Custom OCX I Use In The Application? (This Is Just A Composite Of ListBox And A Text Box.)

Suggestions Are Wanted.

Returning Error From Function
Hi all! Been a while. Hope you all are having a wonderful holiday.

Onto my question...

Excel spreadsheets have built-in error handling for issues on worksheets. For instance, if you put 'a' into cell A1 and placed the formula '=INT(A1)' into cell B1, it would display '#VALUE!' as the result.

I want to be able to duplicate this functionality using a function I build. Here's a rather bad example of what I'm looking to do:

Code:Public Function MakeUpperOrAddTen( _
    ByVal strOriginal As String) _
    As String

    If Len(strOriginal) = 0 Then
        ' RETURN #VALUE! HERE.
    Else
        If IsNumeric(strOriginal) Then
            ' Parameter is numeric. Add 10 to it.
            MakeUpperOrAddTen = CStr(Val(strOriginal) + 10)
        Else
            ' Parameter is alphanumeric. Make upper case.
            MakeUpperOrAddTen = UCase(strOriginal)
        End If
    End If
End Function

In the above example, I want the function to return an error to the calling worksheet if the parameter is empty. I do not want to simply return the string "#VALUE!". Instead, I want Excel to react just like it does on any other error (exclamation mark popup, response to the function ISERROR(), response to other functions such as LEN(), etc.).

Please tell me this is possible.

As always, I appreciate the thoughts and help. Thanks.

Tristan Wolf

Confucious say, "Man who fight salmon should use right hook."

Returning An Error To Calling Application
Hi All.

General question. If I create a VB application (V6.0) that is run from the command line how to I return an error (if there is one) to the program that called the VB command line app to begin with?

I know my question is a bit vague but the best I can do at the moment.

Thanks

Brent

MSDOS Returning An Error To VB Program?
I've got my program where it will shell out to DOS and extract the files from within the .zip file, but if it encounters an error it still doesn't let my program know and therefore the user will not know. How can I have MSDOS return an error window to my program if it does indeed encounter an error.

Thanks

ThE fReEzEr

Returning Error Code To Shell
I have a standard EXE
I will be running it in command prompt.
I want my exe to return status to the shell. How can I make my standard exe to pass messages to shell.

My problem is if there was some problem so that the exe has to stop executing I have to return a message at the command prompt, with the error code returned to the shell.

How can I do that?

Thanks
Ramdas

Returning Error Raised By Stored Procedure In VB6
I am calling SQL stored procedures in my VB application. I am successful in connecting and executing the stored procedure. But I still need to get the errors raised by my stored procedures. Can anybody help me on how to do this? Any sample code? Thanks.

Dlookup Returning Null Value And/or Runtime Error
I am having a problem with dLookup, I have a Table called detail two of the fields are called product and desc. on my form I have a text box called Prod ref, that I type the product number in called Prod ref and have a button that when clicked it should return the desc from the detail table but its not !?! Im am useing this code :
    Desclook = DLookup("[Desc]", "Detail", "[product] = " & Prod_Ref)
    Description.Value = Desclook
    Debug.Print Desclook

As you can see i am calling debug to find out what it is returning and it keeps coming up with Null.
Some times I will get a run time error but I haven't writen it down
Please can any one help me
Thanks


MSAccess: Concatenation In Control Source Returning #Error
On my report I have a textbox whose control source SHOULD be as follows:

=[Name] + " lives at " + [Address]

I've also tried this with "&" to no luck. This sounds simple, and I've had it working at other locations.

=[Name] - Returns "Jeff"
=[Address] - Returns "999 Cherry St"
=" lives at " + [Address] - Returns " lives at 999 Cherry St"
=[Name] + " lives at " - Returns "#Error"
=[Name] + " lives at " + [Address] - Returns "#Error"

So I tried using CStr, and it gave me Error 0.

=CStr([Name]) + " lives at " + [Address] - Returns "Error 0 lives at 999 Cherry St"

I've tried everything I know to isolate the problem, but I can't see anything other than this field is just not being cooperative. The [Address] field is IDENTICAL to the [Name] field except for data. Any clues?

Edit: UPDATE: =[Name] Returns #Error as well!! What in the WORLD is going on?!?!

Data Reports Returning Run-time Error 3705
I am running some data reports in my application using visual basic. My main menu links to a data report which is attach to a query that requires a start date and ending date. It works fine if I only run the report once. If I close the data report and try to run it again I get the runtime error 3705 Operation is not allowed when the object is open. I'm assuming I'm closing the report because I'm click on the corner X but apparently I'm doing something wrong. How can you close the object? Or is there any other way to handle this? I hope my explanation makes sense.
Below is the code I'm using to run my data report.

Thanks.

Private Sub cmdItemByDateRange_Click()

    On Error GoTo cmdItemByDateRangeErr
     
    StartDate = InputBox("Starting Date", "Enter BEGIN_DT (Example - 01/01/04)", "1/1/2004")
    If Len(StartDate) > 0 Then
        If Not (IsDate(StartDate)) Then
            MsgBox "Report Canceled, Wrong Date Format"
            Exit Sub
        End If
    Else
        Exit Sub
    End If
    
    EndDate = InputBox("Ending Date", "Enter ENDDT (Example - 01/01/04)", "1/1/2004")
    If Len(EndDate) > 0 Then
        If Not (IsDate(EndDate)) Then
            MsgBox "Report Canceled, Wrong Date Format"
            Exit Sub
        End If
    Else
        Exit Sub
    End If
    
    ' Assign variables to command
    PawnShop.SearchByDateRange3_Grouping StartDate, EndDate
    
    ' Change report orientation
    rptDateRange.Orientation = rptOrientLandscape
    
    ' show report
    rptDateRange.Show

cmdItemByDateRangeExit:
    Exit Sub

cmdItemByDateRangeErr:
    MsgBox "Error: " & Err.Number & " " & Err.Description
    Resume cmdItemByDateRangeExit
End Sub

Oracle- Error Returning A VarChar From Stored Procedure
Hi,
 When I try to return a varchar from my stored function(Oracle) I get the following error. But when i change the function and return an integer it works fine. Here is the code and the error message. Can anyone point to me what is wrong?.
Regards,
Sachin.

myConnection.Open()

Dim selectCmd As New OleDb.OleDbCommand("test2", myConnection)

selectCmd.CommandType = CommandType.StoredProcedure

 Dim ReturnValue As OleDb.OleDbParameter = Selectcmd.Parameters.Add("ReturnValue", OleDb.OleDbType.VarChar)

ReturnValue.Direction = ParameterDirection.ReturnValue

'Input parameters

selectCmd.Parameters.Add(New OleDb.OleDbParameter("@customer_no_", OleDb.OleDbType.VarChar))

selectCmd.Parameters("@customer_no_").Direction = ParameterDirection.Input

selectCmd.Parameters.Add(New OleDb.OleDbParameter("@credit_card_id_", OleDb.OleDbType.Integer))

selectCmd.Parameters("@credit_card_id_").Direction = ParameterDirection.Input

'Assign Values

selectCmd.Parameters("@customer_no_").Value = "1000"

selectCmd.Parameters("@credit_card_id_").Value = 1

'Execute the function

selectCmd.ExecuteNonQuery()

Dim a As String = selectCmd.Parameters("ReturnValue").Value

Response.Write("Value" + a)

myConnection.Close()



The error I get is

System.InvalidOperationException: Parameter 0: 'ReturnValue' of type: String,
the property Size has an invalid size: 0 at System.Data.OleDb.OleDbParameter.ValidateParameter()
at System.Data.OleDb.OleDbParameter.BindParameter(Int32 i, DBBindings bindings, tagDBPARAMBINDINFO[] bindInfo) at System.Data.OleDb.OleDbCommand.CreateAccessor() at System.Data.OleDb.OleDbCommand.InitializeCommand(CommandBehavior behavior, Boolean throwifnotsupported) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at WebApplication2.WebForm1.DEDR_Update(Object Sender, DataGridCommandEventArgs E)
in C:Inetpubwwwrootc$inetpubwwwrootWebApplication2WebForm1.aspx.vb:line 472



If I change the function to make it to return a number it works fine.

Dim selectCmd As New OleDb.OleDbCommand("test3", myConnection)

selectCmd.CommandType = CommandType.StoredProcedure

 

Dim ReturnValue As OleDb.OleDbParameter = Selectcmd.Parameters.Add("ReturnValue", OleDb.OleDbType.Integer)

ReturnValue.Direction = ParameterDirection.ReturnValue

'Input Values

selectCmd.Parameters.Add(New OleDb.OleDbParameter("@customer_no_", OleDb.OleDbType.VarChar))

selectCmd.Parameters("@customer_no_").Direction = ParameterDirection.Input

selectCmd.Parameters.Add(New OleDb.OleDbParameter("@credit_card_id_", OleDb.OleDbType.Integer))

selectCmd.Parameters("@credit_card_id_").Direction = ParameterDirection.Input

'Assign Values

selectCmd.Parameters("@customer_no_").Value = "1000"

selectCmd.Parameters("@credit_card_id_").Value = 1

'Execute the function

selectCmd.ExecuteNonQuery()

Dim a As Integer= selectCmd.Parameters("ReturnValue").Value

Recordset Only Returning Five Records When It Should Be Returning 466
All,

Doing this in excel with VBA. Haven't working in VBA for a very long time but can't see why I'm getting these results.

I run this sql in query analizer and I get 466 records back but when the same sql runs in vba I only get five records back. I checked the conn string to make sure I was running against the correct db. Is it that I'm not setting up my recordset object correctly?

Code:
Set conSql = New ADODB.Connection
    conSql.Provider = "SQLOLEDB"
    conSql.ConnectionString = "Data Source = Test1;" & "User ID=sa;Password=test; Initial Catalog = test;"
    'conSql.ConnectionTimeout = 120
    conSql.Open
    
    Dim strSql As String
    Dim fldField As ADODB.Field
    Dim docXML As New MSXML2.DOMDocument
    Set rstData = New ADODB.Recordset
    
    strSql = "SELECT CedingCoID, effectivedate, XMLString " & _
                "FROM CAPSProgram " & _
                "Where ID > 1 and CedingCoID > 1" _
          ' "WHERE (CedingCoID = '" & intCedingCoID & "' AND EffectiveDate = '" & CDate(datEffectiveDate) & "' AND Description " & IIf(strDescription = vbNullString, "IS NULL)", " = '" & strDescription & "')")

    rstData.Open strSql, conSql, adOpenForwardOnly, adLockReadOnly
    'Set rstData = conSql.Execute(strSql)
    Do Until rstData.EOF
       ' If Not rstData.EOF Then
            globEffectiveDate = rstData.Fields("effectivedate").Value 'set global effective date for future use
            docXML.LoadXML (rstData.Fields("XMLString").Value) 'load glabal xmldoc for all load routines
            globCedingCoID = rstData.Fields("CedingCoID").Value
              Call LoadCapsProgram(docXML)
            Call LoadCapsLossHisEvents(docXML)
            
            
        'End If
      rstData.MoveNext
    Loop
    

Returning Class Variable. Getting Runtime Error "91"
I have Class module defination like this:I have another Class1 declared somewhere. This is class 2. I get error as below.


Code:
Private q() As Class1
Private i As Integer

Public Function pop() As Class1
Dim Index As Integer
ReDim Preserve q(i) As Class1
pop = q(i)
' I get error here "object variable or With block variable not set". Run-'Time Errror "91"


i = i - 1

End Function

How can i solve this??

Returning Value
I'm using the following command to make a sum from a range of cells.


Code:
Dim Pa As Integer
ActiveCell.Offset(1, 5) = WorksheetFunction.Sum(Sheets("BOMA").Range("F5", Sheets("BOMA").Cells(Range("F65536").End(xlUp).Row + 1, 6)))
Pa = ActiveCell.Offset(1, 5)

The program return an error and stops at Pa = ....
Debug shows that Pa = 0 even though the sum in this cell are something else.

Some ideas

Returning From A Sub
Can any one tell me is there a way to return from a sub function
such as:
sub Replace()
blablabla
end sub

is there a way to return to the place in another function where I called this sub from?
if not is there another way I can run the same procuder and come back to my starting point?

Returning A Value From A Sub?
well I have something along the lines of

VB Code:
public sub returnTest(theNum As integer)if theNum = 1 then'return something elseend ifexit sub

But, I don't know how to return something in vb.
I would like to use this sub like..

VB Code:
testVar = returnTest(1)

Returning A Value From An Exe
Hello,

I am trying to make an exe which returns a value to the command prompt when run through the command line. I am using cmd line parameters..

Thanks
Ajit

Mts, Vb6, W2k, Not Returning
It's only been a week and it's time for me to throw this out to bigger brains then mine.

I have a vb6 app that uses MTS objects to retrieve data and do other nifty db stuff. When it was on nt4 I wrote a report engine that used MTS and generated a html report for the user. Dam* users now want me to implement it on w2k.

I register the dll in component services, run the control on the client that calls it:


VB Code:
Set obj = CreateObject("RDS.DataSpace")  Set report = obj.CreateObject("DCISReportEngine.Report", sServer)  'Set report = obj.CreateObject("DCISReportEngine.Report", "localhost")         'should return report url                strURL = report.GenerateReport(Conn, sServer, sSQL, sRepDef, boolDup, boolGroup)


Now running locally it runs fine. But when the code above runs it creates the object (starts the package running on the server) but
returns a null string. It should return a string with a url in it.

So I ask what am I not getting? I added a log file to the MTS dll and it doesn't create the log so I'd guess it doesn't run.

But nothing tells me that it doesn't.

Suggestions? Mine regarding giving back my nt4 have gone unanswered.

Thanks for your time,
Dave

Returning Value From Exe
Hi,

Thanks for reading. I want a VB exe which should return a value say some success or failure regarding the operation happening inside it. Just like a C++ program returning a value to the console. And I want my java program to read this. How can I return the value from my VB program?


Thnx,
Pres.

I Really Don't Know (returning A Value)
My problem is kinda complicated. I have made my own msgbox because the normal msgbox freezes my program and that's not good. But now I can call the function. This opens a form and if it's already openend it put's the info into a type MSGINFO. So far so good. That form raises an event to tell if a button got clicked. Now when that happends I want to return the value to where the sub got called. And that's not possible (I think). But I don't want the sub wich calls the msgbox form to use something like:

DO
DOEVENTS
LOOP until Clicked

and then save in the boolean clicked if it got clicked cause that uses to much resources and gives up to much time. It's kinda complicated but I hope someone has got an answer.

Why Is It Returning Nothing?!?!?
I have this code piece to try and convert a month in numbers to the actual month like 11/ would be november. But I get a blank msgbox when I try this code and I can not figure out why! thanks for any help!

Dim strdate As String
Dim strmonth As String
Dim theday As String
Dim str2 As String
Dim strday As String
Dim chkmonth As String

strdate = Text1.Text

If Left$(strdate, 3) = "/" Then
Select Case Mid(Text1.Text, 1, 2)
Case "10"
str2 = "October"
Case "11"
str2 = "November"
Case "12"
str2 = "December"
End Select
strmonth = str2
End If
MsgBox strmonth

API Returning Nothing
I got a few problems...
What do you do when you use a GetText Function to get the text on a window and nothing comes back? Like you know for a fact your code is right and bug free. I thinking the window has something blocking API or something. Some windows and objects dont let you use API on them is that possible? Some windows/objects you can't hide. Like Ad bars that dock on ur computer and stuff. How can you hide em? Also I know of one window i have you can SEE it has a title bar and a caption in it, but an API spy can get it's caption.
- How do you get around all of this? -
- How can I hide the windows i want to hide, and get text from objects that have text in em like a text box or maybe password box, or even a label, and captions? -
Maybe theres something I would use instad of API??
Please help...

My GetText Function:

Code:
Public Function GetText(WindowHandle As Long) As String
Dim TheText As String, TL As Long
TL = SendMessageLong(WindowHandle, WM_GETTEXTLENGTH, 0&, 0&)
TheText = String(TL + 1, " ")
Call SendMessageByString(WindowHandle, WM_GETTEXT, TL + 1, TheText)
TheText = Left(TheText, TL)
GetText$ = TheText
End Function

Returning A Value
So I'm working on my gradebook programme. As mentioned in other posts I'm a teacher though not of computers - that's just a hobby.
I have a form with 5 textboxes in an array txtMark(0), txtMark(1) etc.
Each one contains a mark for a quiz. Now, if a student is missing a mark due to absence or something I want to recalculate the average based on the number of marks available. If there are only 4 marks then the divisor for that average should be 4.

Here is my code for the command button to calculate the average

Private Sub cmdAverage_Click()
intDivisor = txtMark().Count 'sets the divisor to the same number as there are textboxes
ReCalc (intDivisor)
Dim i As Integer

intTotal = Val(txtMark(0).Text) + Val(txtMark(1).Text) + Val(txtMark(2)) + Val(txtMark(3)) + Val(txtMark(4))
 'I know that line is clumsy - I'll tidy it up later
txtAverage = CInt(intTotal / intDivisor)
End Sub

I also have a function ReCalc which is supposed to iterate through the text boxes and if any of them are empty, the divisor should be reduced accordingly:

Public Function ReCalc(intDivisor) As Integer
Dim i As Integer
Dim ctr As Integer
ctr = 0
Dim ctl As Control
For Each ctl In Controls
    If TypeOf ctl Is TextBox Then
        If ctl.Text = "" Then
            ctr = ctr + 1 ' supposed to count how many text boxes are empty
            intDivisor = intDivisor - ctr 'supposed to reduce the divisor by the number of textboxes that are empty
        End If
    End If
Next ctl

End Function

Unfortunately it just doesn't work. intTotal is always divided by 5 regardless of how many textboxes contain text. I'm not getting any errors so it must be a logic error but I can't see it. Any help?

Thanks For Returning...
Hi,

I juz like to thank the adminstrators of this discussion board...I had so many questions regarding vb programming during the time the board was not functioning and felt so helpless... I took a long time to figure out how to solve problems compared to when I can juz pose the questions to ppl who help out with answering of questions on this board.

Juz to show my gratitude
Adrel

Returning Mouse Down
Hey, I'm making a game and I have a bunch of Shapes on my form. When a user clicks on one of the shapes I would like it to return which shape it is so I can add a color to the shape that is clicked.

Example:

o o o o o <----Shapes (In an array 0-4) called shapePeg

^ ^ ^ ^ ^ <----Colored Shapes named shpRed, shpYellow, shpBlue, shp Green shpOrange

now say the user clicks on the shapePeg(2) shape, I want it to return that shape so that when the user clicks on one of the color shapes, the color will then go into the shapePeg(2)

I hope it isn't to confusing.

Help Returning Line Set?
Hi, i have the following problem.


I have a 6 multine textboxes not linked to eachother in any way, EXCEPT.. that they contain information wich is related to eachother..

like this :

Code:

text1: text2: text3: etc

info1 info2 info3
info1 info2 info3
info1 info2 info3
info1 info2 info3
as you can see, the first line of text1 .. contains information relevant to the same line in text2/text3/text4/text5/text6.
if you still dont understand 1 more example :

say we have a chair.. and we put it in a table.


Code:

colour type serial

blue antique 123-3472
red old-style 234-4567
now i want those information bits to be linked to eachother by counting the lines on wich they exist.

say i would want to see what would exist on lines 100~200

so therefor i would need it to do this :

1. Count the lines in text1 , start reading from line 100 .. and stop at line 200
2. print those in any way ( im going to write them to a textfile ).
3. then do point 1 for text2 till text6. and print those also.


how would i go by this?
i know how to count the lines and all that

Code:
Private Sub Count_Click()
Dim Pieces1() As String
Dim string1 As String
Dim lines As Integer
Dim i As Integer


string1 = Text1.Text


Pieces1 = Split(string1, vbNewLine)

For i = LBound(Pieces1) To UBound(Pieces1)

lines = lines + 1
Count.Text = lines

Next i

End Sub
but then i wouldnt know how to read the content of that single line, and even how to read multiple lines.


Please help me with this!

thank you
Jeroen van Vierzen

Old Toolbar Keeps Returning
Hi all,

Has anybody had problems changing to a later version of a custom toolbar.

I have a toolbar that has a menu on it, once an option is clicked it runs a small VBA program. This toolbar was attached the workbook and when opened appeared on the receiving PC.

I added some more options a while ago and I had a lot of problems getting the new toolbar to appear. Again I've added more options and now I'm pulling my hair out because the toolbar is reverting back the original one, version 1.....

I've asked the user to delete the original file and toolbar. There is now nothing on the machine relating to my custom toolbar. I have then deleted the attached toobars from my workbook and saved. Next step is to reattach the latest toolbar to my workbook.

Again the user still gets the old toolbar from 2 versions ago.

Help!!!!!!

Cheers
Tom

VBA: Returning The Top 'x' Results.
I need to display 'x' number of results.

The 'x' is user defined.
The results are generated by a Query then displayed by a report.

I have tried the SQL TOP command, but it appears you cannot link that to an input box located on a Form direct to the Query.

I have tried to generate an incrementing number field in the query, but this was also to no avail. If this would have worked then I could simply limit the amount to display.

Any ideas on this are greatly appreciated.

Cheers,

Si.

Returning A Value, Not A Formula
Hey all, I need a little help with something pretty basic. I have a macro that performs a simple calculation. How do I return only the result, the integer information, to the cell without the formula tracking along with it?

ActiveCell.FormulaR1C1 = "=R[-1]C+1"

Thanks for any help on this!

XLS MsgBox Returning A Value
I'm an idiot. I'm sure this is a super easy fix and I'm just overlooking something.
Heres what I have


Code:
Private Sub Validate()
Dim EmpName As String
EmpName = Range("B2").Value
Ans = MsgBox("Are you" & " EmpName " & "?", vbYesNo, "Validating")
Select Case Ans
Case vbYes
' Code for yes
Case vbNo
Range("B3").ClearContents
Call GetName
End Select
End Sub
The Message box shows "Are you EmpName?" It doesn't show like, "Are you DrSwaity?" if thats what was in B2. I think it looks good, but obviously not.

One consideration is B2 contains a "=vlookup" formula. There is a value in the cell...

Anyways, thanks in advance!

Returning A String From A VB6 Std DLL
I have created a standard (not ActiveX) DLL from VB6 and am trying to return a string to the calling application from the DLL function. The problem is that the string returned is in wide character format (nulls in between characters)...is it possible to return it in narrow character format (no inter-character nulls)?

Returning The Address
i whouldnt know what to google to find the answer to this so ill ask on a fourm. i whould like to make a program that can copy itself to another directory. i know how to copy just fine, my problem is that, i dont know how to return the current address of the program. say someone downloads my progam and saves it were ever(c:/downloads/stuff/) for example. how do i make my program return (c:/downloads/stuff/myprogram.exe) as a string, so i can make it copy it and save it to another directory?

Returning Focus To VB
I have a VB program which instructs an Application (AutoCAD), to do a number of things, including "zoomAll". THis sets the focus on the AutoCAD application. Then to proceed with the VB program's Code, I always have to manually click on the VB interface. This returns the focus to the VB program and so teh VB code is resumed.

The problem this is to be a server program so I need ensure that the focus is returned to the VB program automatically.....Any suggestions would really be appreciated.

Thanks

Gwyn

Returning Filenames
Hello.

Does anyone know how to return a list of filenames from a folder.

In a folder say H:Folder there would be some documents. Documentx, Documenty, Documentz. I would like to populate a list in excel with these filenames.

Hope this makes sense.



Martin

Returning The Value From A List Box
Alright, I have a list box and im using my variable.listindex which gets the value of the row that i have selected but i want to take the value that i have in the row. So just tell me.

Returning A Variable
Ok ive made an object, but there is still once piece of code i cant figure out. The object has a few variables (Dim Id As Integer), and has a function to give it the Id. But now If i want to call the ID while the program is running, how do I do it? I have another function called getID() but Im not sure what the command is so i can call that variable and use it. (similar to the return variable command in Java)

Dir Function Returning . And ..
I'm using the dir function to populate an array with the names of folders on a drive. It works fine if you specify the root folder

ex.
sFolders = Dir("f:", vbDirectory)

but if i specify a subdirectory, like this

sFolders = Dir("f:sub", vbDirectory)

it lists all the subdirectories off of f:sub but it also lists "." and ".." for the first two elements of my array.

Is there a way to stop this?
Also, is there a difference between dir() and dir$()

thanks

Returning Day Of Week
is there a simple function in vb that can return the first day of a given week.

for example week 3 in 2003 gives 13 januari

thnx for the help

Returning Enum
Module:

Code:
Enum type_Defcon
blue = -1
green = 0
yellow = 1
red = 2
End Enum

Public Defcon As type_Defcon
Form:

Code:
Private Sub Form_Click()
Defcon = Defcon + 1
If Defcon > 2 Then Defcon = -1
Debug.Print Defcon
End Sub
This will print the value of Defcon. But how can I print the names? like blue, green etc.

Returning ListIndex
How do i return the listindex from a item in a listbox if i only know the text?

i know how to return the text if you know the listindex

SelItem = List1.List (List1.ListIndex)

But the other way round isn't working...

Returning A Pointer From A DLL
Hi All,

This may be a stupid question (there are no stupid questions, just stupid people asking questions)....

This is my DLL function that returns a pointer to a buffer variable that is passed, as a pointer, the function:

char *PROG_GetHome(char *buff);

and I am trying to build the VB code that calls this function and I am having a little trouble.

Any ideas?

Thanks much, DM

Returning Printer Name
I have an application where I need to store a users selection of up to 6 different printers (various default label printers, etc). I am trying to use the Common Dialog to allow the user to select a printer to store, but cannot determine how to find the printer name once returned from the selection using the control.

Thanks in advance.

Returning An Array
how can i return an array from the function?


waqas

Returning Values From A VB Exe
Hi All,
I am trying to write an exe file (required by a 3rd party vendor I am integrating my system with) that accepts an arguement (the ID of a particular record in a database) and select the values from the tuple associated with the ID from the database, concatenate the selected fields and return this concatenated string.

Is this at all possible. I mean if i create a standard exe, it is the form_load that runs and since it is a Sub it cannot return a value. I cannot use a dll because the vendor explicity states that an executable (exe) file must be used. It is their system that calls my exe file and I do not have control over how it calls my file. All it does it call my file with an input paramenter and expects the string returned when it calls the exe.

Any help is greatly appreciated. I am a novice to VB and I do apologise if my question sounds silly.

Thanks a million.

MI

Function Returning A Value
Could someone show me a quick demonstration of calling a function, and having that function return a value?

Returning A Value From A Form
Hi all,

I'm probably being dense here, but could someone enlighten me on how to return a value from a form in VB6?

Thanks,

-Utini

Returning DOS App Results
Is there a function to return the results of a DOS program into a variable? eg,
xxx ("C:windowssystem32ping.exe google.com", result) would return the output you'd get if you typed that into a dos prompt into variable result? Thanks

Returning Key Value From A Collection
Is there a way to return the key values from a collection?

Here's some code to illustrate what I mean:


Code:
Public Sub Save()
Dim fso As New FileSystemObject, ts As TextStream
Dim outputLine As String, i As Integer, setting As String
Set ts = fso.CreateTextFile(mFilename)
For Each setting In Settings
outputLine = setting.key & "=" & setting '<- if only this worked....
ts.WriteLine outputLine
Next setting

ts.Close

Set ts = Nothing
Set fso = Nothing

End Sub

Of course, the setting.key is invalid. What I want to do is find both the value of each member of a collection, and also the value of the key for each member. I supose I could just rewite the class to store the key and value in a small array, but I was hoping to make a shortcut in this way...

Any suggestions?

Returning The Value Between Two Characters
If i have

<one two three> how do i get the values between the < and the >?

thanks

Copyright © 2005-08 www.BigResource.com, All rights reserved