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




Boolean Function Return Value


just want to make sure here.. i tested it, but wanted to know if there were any exceptions..

a function that returns a boolean will always return false by default correct? Unless it is set to true it will never default to true right?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Get A Usercontrol Box To Return Boolean
I know how to send data to a Usercontrol. Now i need to use it to return a boolean, number, anything back into my form to check if something is set, or the right color, etc.

Return Values From Boolean
Hi,

Is there any builtin function which will give value 1 for True and value 0 to false. I have following function:
VB Code:
Private Function BoolToVal(ByVal blnTemp As Boolean) As Integer'This function will return 1 if the value is true else will return 0    If blnTemp = True Then        BoolToVal = 1    Else        BoolToVal = 0    End IfEnd Function

How To Return A Boolean Value On SQL Query...
Hello,

I have an application where I need to check two different Datagrids to see if there is identical data in each of them.  I simply need to know if there is identical data (true) or not (false) and have that return from a function.  I will make this query quite a bit as data arrives in the two tables.  I am new to this SQL stuff so sorry if this is so basic... Thanks though...  Please let me know if I need to elaborate more on this.  

LF

Boolean Function Error In Loop...HELP!!!
Im writing a hangman game for school, im getting an error that says arguement not optional where it says 'IsSolved = False', can anyone help me out??

Do
blah = DisplaySecretWord(Solution)
blah = DisplayGuesses(Guesses)
blah = FillSolution(SecretWord, Guesses, Solution, GuessNum)
blah = IsSolved(SecretWord, Solution)
blah = DisplayHangman(GuessNum)
Loop While IsSolved = False Or GuessNum < 8

Boolean Search Function [Unresolved]
This is a boolean search method, and I'm having minor problems with it. It works great, but once I enter something like "link in park" then it freezes up (bottom loop). Once you get above 3 search terms without an AND/OR/etc. seperating them, it freezes. Anyone know how to fix this problem? ALso any coding optimizing would be great. Thanks!



Code:
Public Function CheckString(ByVal Query As String, test As String) As Boolean
'query is something like "Ashley and Harris and not Maxwell"
'test is the string in which to search, ie "Ashley Maxwell Harris"
' (this example would not match, as maxwell was present)

If Query = "" Then Exit Function
'query is a string you'd pass to a search engine like altavista etc. ie:
''animal AND (bear OR "Baby fox")'
Dim s As Long, f As Long, a As Long, b As Long
Dim i() As String, j() As String

On Error GoTo 0

s = InStrRev(Query, "(")
morebrackets:
If s > 0 Then
f = InStr(s, Query, ")")

If f > 0 Then
Query = Mid(Query, 1, s - 1) & UCase(CBool(CheckString(Mid(Query, s + 1, f - s - 1), test))) & Mid(Query, f + 1)
End If
End If

s = InStrRev(Query, "(")
If s > 0 And f > 0 Then GoTo morebrackets

'remove any invalid characters
Query = Replace(Query, "?", "")
Query = Replace(Query, " ", " ")
Query = Replace(Query, vbCr, "")
Query = Replace(Query, vbLf, "")
Query = Replace(Query, vbTab, "")
'query = Replace(query, " ", " ")
Query = Replace(Query, ".", "")
Query = Replace(Query, "(", "")
Query = Replace(Query, ")", "")


i = Split(Query, " ")

'ok, this is weird, say this split resulted in:
' 'Bear' 'OR' '"Baby' ' fox"'

'turn it into: 'bear' 'OR' 'Baby Fox'


If InStr(1, Query, """") Then

For a = UBound(i) To 0 Step -1
If Right(i(a), 1) = """" And Left(i(a), 1) <> """" Then
i(a - 1) = i(a - 1) & " " & i(a)
i(a) = ""
End If
If Right(i(a), 1) = """" And Left(i(a), 1) = """" And Len(i(a)) > 1 Then
i(a) = "!" & Mid(i(a), 2, Len(i(a)) - 2)
End If
Next a

'remove the nulls
b = 0
For a = 0 To UBound(i)
If i(a) <> "" Then
ReDim Preserve j(b) As String
j(b) = i(a)
b = b + 1
End If
Next a

i = j
Erase j
End If
'now, do the actual searching for each string
For a = 0 To UBound(i)
Select Case UCase(i(a))
Case "AND"
i(a) = "AND"
Case "OR"
i(a) = "OR"
Case "NOT"
i(a) = "NOT"
Case "XOR"
i(a) = "XOR"
Case "TRUE"
i(a) = "true"
Case "FALSE"
i(a) = "false"
Case Else
If Left(i(a), 1) = "!" Then i(a) = Mid(i(a), 2)
i(a) = LCase(CBool(InStr(1, test, i(a), vbTextCompare)))
End Select
Next a


'we now have a boolean expression on our hands:
'false AND true XOR false
Query = Join(i, " ")
Erase i
'this is cheating, I know, but, It's quicker then parsing out the
'proper way, so...
keepgoing:

If InStr(1, Query, "NOT") > 0 Then
Query = Replace(Query, "NOT false", "true")
Query = Replace(Query, "NOT true", "false")
End If

If InStr(1, Query, "OR") > 0 Then
Query = Replace(Query, "false OR false", "false")
Query = Replace(Query, "true OR false", "true")
Query = Replace(Query, "false OR true", "true")
Query = Replace(Query, "true OR true", "true")
End If

If InStr(1, Query, "XOR") > 0 Then
Query = Replace(Query, "false XOR false", "false")
Query = Replace(Query, "true XOR false", "true")
Query = Replace(Query, "false XOR true", "true")
Query = Replace(Query, "true XOR true", "false")
End If

If InStr(1, Query, "AND") > "0" Then
Query = Replace(Query, "false AND false", "false")
Query = Replace(Query, "true AND false", "false")
Query = Replace(Query, "false AND true", "false")
Query = Replace(Query, "true AND true", "true")
End If
recheck:
If InStr(1, Query, " ") > 0 Then
Query = Replace(Query, "true true", "true")
Query = Replace(Query, "false true", "true")
Query = Replace(Query, "true false", "true")
Query = Replace(Query, "false false", "false")
If InStr(1, Query, " ") > 0 Then
Query = Query & " false"
GoTo keepgoing
End If
End If

CheckString = CBool(Query)
End Function

Help Needed Please In Writting A Boolean Function In VBA?
I wanted to know how to write a Boolean function in vba, that checks all the records of two fields in a form. The Function should return true if all the Football result is Win and false if any of the football result is lose

Zub

<Edit> Lankymart - Moved from VB & Databases to more relevant forum. </Edit>



Edited by - lankymart on 9/20/2007 9:35:52 AM

Changing The Value Of A Public Boolean By Calling A Function From Another Wb
Not sure why this doesn't work. Can someone shed some light on this?

In Wb1

Code:
Sub Run()
Dim File As WorkBook
Set File = Workbooks.Open("Wb2.xls")
Application.Run File.Name&"!SetBreakFlag"
File.Close
End Sub

In Wb2's Workbook page

Code:
Public BreakFlag As Boolean

Private Sub Workbook_Open()
BreakFlag = False
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If BreakFlag Then MsgBox "flagged"
End Sub

In Wb2 module 1

Code:
sub SetBreak()
BreakFlag = True
End Sub

Everything seems to work fine but "flagged" never appears. If I follow the execution I find that SetBreak runs and sets BreakFlag = true, but afer the SetBreak subroutine is finished BreakFlag is still returned as false. How do I get BreakFlag to stick?

Summing And Printing Out Result Of Boolean Function
Okay I am new to VB 6 and am doing a mini project for one of my classes. Basically what the pgrm does is that it picks 10 out of 52 card deck, displays the value, and i wrote a function that says if a card is Red, or not. What I need to do is have a printout below that totals up the number of Red cards, here is my function that I wrote:


Function Red(ByVal I As Integer) As Boolean ' Returns a True or False value if the card is Red or not

Dim VALUE As Integer
Dim SUIT As Integer

Call CardPower(CardName(I), VALUE, SUIT)

If SUIT = 1 Or SUIT = 2 Then

Red = True

End If


End Function

Return Value From One Function To Another
Hi. this is my first post, so be gentle........

I am using a program called QuickTestPro that uses VBA as its coding language. The question that I have is this:

how do I return a value from function 2 to function 1.

what I have is this:

function1()
dim trade
trade=function2(some other variables)

function2(some other variables) as String
return trade
end function

is this correct?

Thank you.

Return Value From Function
hello

i'm writting a function to execute sql queries, but i get an error when i try to write the 'return ' statement, for example:


Code:
Function query(ByVal q As String) As ADODB.Recordset
Dim arset As ADODB.Recordset
arset = dbconn.Execute(q)
Return arset 'error 'Expected: end of statement'
End Function

the error happens when i'm writting the code, not at runtime, could you thell me how to return a value from inside a function?

thank you

Function Return
Hello All,
I hope someone can help. I'm not using a formal VB edition, just 'messing about' with the VB editor behind MS Excel.

My problem is this:
I have created a data type using 'type' keyword (as below). I have created a function which creates a new instance of this ?object. That works fine in its own right.

What I want to know is- How do I return the newly created 'agent' to the sub procedure ('agentMain') and assign it to an 'agent' instance I've created in 'agentMain'?

I hope this makes sense- I've tried everything my sad and pathetic knowledge of VB can think of- Anyone who can help me would become a true hero (or heroine) of mine!!!

Martin



Type Agent
AgtName As String * 30
AgtCity As String * 20
AgtCharisma As Integer
End Type


Sub agentMain()

Dim testAgent As Agent

End Sub


Function AddAgent()
Dim NewAgent As Agent
Dim AgMsgBxNmPrt, AgMsgBxTtle, AgMsgBxNmDflt As String
AgMsgBxNmPrt = "Enter Agent Name"
AgMsgBxTtle = "Create New Agent"
AgMsgBxNmDflt = "New Agent"
Dim AgMsgBxCyPrt, AgMsgBxCyDflt As String
AgMsgBxCyPrt = "To Work in Which City?"
AgMsgBxCyDflt = "London"

With NewAgent
.AgtName = InputBox(AgMsgBxNmPrt, AgMsgBxTtle,AgMsgBxNmDflt)
.AgtCity = InputBox(AgMsgBxCyPrt, AgMsgBxTtle, AgMsgBxCyDflt)
.AgtCharisma = Int((10 * Rnd) + 1)
End With

MsgBox (NewAgent.AgtCharisma)

End Function

Function Return Value
Hi Everyone,
i'm trying to assign a value to a variable from a function but its not working. This is the code I have so far:


Code:
'call
intWeekDay = convertWeekDay(3)

'function
Private Function convertWeekDay(weekDays As Integer) As Integer

Select Case weekDays

Case 1: weekDays = 2
Case 2: weekDays = 3
Case 3: weekDays = 4
Case 4: weekDays = 5
Case 5: weekDays = 6
Case 6: weekDays = 7
Case 7: weekDays = 1

End Select

End Function

So that should make intWeekday = 4. But it says it equals 0. The function works fine. I have debugged it.

Does anyone have any ideas.

Thanks a lot for the help

Cheers, Adam

Is There A Function Which Return The .xls Row#?
Hi!

I am working with Excel and VB. I would like to know if there is a function where when I am looping through a range of cells and find what I want(a particular string); I need to find out what row the string is found. Is there such a function?? I looked in the MDSN library , but so far I have not found anything..

Thanks!

Function Only Return ONE Value
Code:
'Only return ONE value'
Private Sub Command1_Click()
Text2 = numbers(Text1.Text)
End Sub

Function numbers(ByVal anyValue)
numbers = anyValue * 2
End Function

'''
'''
'If return TWO value, but wrong?'

Private Sub Command1_Click()
Text2 = numbers(Text1.Text)
Text3 = numbers(Text1.Text)
End Sub

Function numbers(ByVal anyValue)
numbers2 = anyValue * 2
numbers4 = anyValue * 4
End Function


Function only return ONE value ? if use Function return TWO value, function is oke return?

many thanks!

Function Return
I get that I can make something like "Private Function Blah" to return True and False Values, but is there a declaration for functions that I want to return Specific Numbers? (By declaring an integer variable and using something like intReturn = Blah)

Thanks

Function Return
Hi:
I have a class which has two functions:

1. a "GetAllCars()" which has a return type 'Collection' - No parameters passed into it.
2. a "GetCars(ModelYear as string) - which has a return type 'Collection' - Parameter passed into it.

Now, I try to access these functions from my Application:

-------------------------------------------
Dim Coll As New Collection
Set Coll = a.GetAllCars
Dim x as car
For Each x In col
cmb.AddItem x.CarName
Next x
-----------------------------

This does work all right, while the function given below (with input variables) does NOT work!
--------------------------------
Dim Coll As New Collection
Set Coll = a.GetCars("1999")

Dim x as car
For Each x In col
cmb.AddItem x.CarName
Next x
-----------------------------
I get an error message 'Runtime Error 3420 - Object is no longer valid'
Can anybody tell me why?
I use vb6. Thanks for your help.

[function Return]
just a basic question
can a function return 2 values
so yes , how ?

lil example:

Code:
public function something(byval iets as string) as string
dim var1,var2 as string
'in this function iets is splitted in 2 things

var1 = bleh
var2 = bluh

something = var1,var2
'or however
end function
so
how do i return the 2 things

Return Value From Function??
How come when i call for this function in a sub procedure, the msgbox returns me a empty value??


Function convertdte(dteunit As String, dteunit2 As String)

Dim dte1 As String
Dim dte2 As String
Dim dtediff As String

dte = Mid(dteunit, 1, 4) & "/" & Mid(dteunit, 5, 2) & "/" & Mid(dteunit, 7, 2)
dte2 = Mid(dteunit2, 1, 4) & "/" & Mid(dteunit2, 5, 2) & "/" & Mid(dteunit2, 7, 2)

dtediff = CStr(CDate(dte) - CDate(dte2))

End Function

==========================================================

Sub testing()

MsgBox convertdte("20040729", "20040529")

End Sub

Function To Return A Value
i have made a function in a module which is avaliable publically...


Code:
Public Function period(a As Integer)
' extract time from system time in format e.g. 07:55:00 AM
tmTime = Format(Now(), "hh:nn")

If a = "1" Then

If tmTime > "07:45:00 AM" And tmTime < "01:30:00 PM" Then ' if system time is greather than 7:45 AM and less than 1:30 PM

If tmTime > "07:45:00 AM" And tmTime < "08:35:00 AM" Then ' if systemtime is greater than 7:45 AM and less than 8:35 AM
prd = "1" ' set prd (string) as 'Period 1'
End If

If tmTime > "08:35:00 AM" And tmTime < "09:15:00 AM" Then ' if systemtime is greater than 8:35 AM and less than 9:15 AM
prd = "2" ' set prd (string) as 'Period 2'
End If

If tmTime > "09:15:00 AM" And tmTime < "09:55:00 AM" Then ' if systemtime is greater than 9:15 AM and less than 9:55 AM
prd = "3" ' set prd (string) as 'Period 3'
End If

If tmTime > "09:55:00 AM" And tmTime < "10:35:00 AM" Then ' if systemtime is greater than 9:55 AM and less than 10:35 AM
prd = "4" ' set prd (string) as 'Period 4'
End If

If tmTime > "10:35:00 AM" And tmTime < "11:00:00 AM" Then ' if systemtime is greater than 10:35 AM and less than 11:00 AM
prd = "5" ' set prd (string) as 'Recess'
End If

If tmTime > "11:00:00 AM" And tmTime < "11:45:00 AM" Then ' if systemtime is greater than 11:00 AM and less than 11:45 AM
prd = "5" ' set prd (string) as 'Period 5'
End If

If tmTime > "11:45:00 AM" And tmTime < "12:20:00 PM" Then ' if systemtime is greater than 11:45 AM and less than 12:20 PM
prd = "6" ' set prd (string) as 'Period 6'
End If

If tmTime > "12:20:00 PM" And tmTime < "12:55:00 PM" Then ' if systemtime is greater than 12:20 PM and less than 12:55 PM
prd = "7" ' set prd (string) as 'Period 7'
End If

If tmTime > "12:55:00 PM" And tmTime < "01:30:00 PM" Then ' if systemtime is greater than 12:55 PM and less than 1:30 PM
prd = "8" ' set prd (string) as 'Period 8'
End If

Else
prd = "off-time"
End If
End If

End Function


now when i call this function through a form like frm_main like under a timer (interval 5000ms) me.caption = prd

it does not returns the value through the function.

is there a better way to optimize this code and make it work? thanks.

Function Return More Than One Value
I know this is a stupid question but I've never needed to do this until now. How can I make a function return more than one value? For example, if I want a function to return the time, day, month, and year all in different variables, how would I do this? Thanks

Function Return Value
I have a function as boolean in a class. I can call the function using <classname.function function variables> (without <>). In the function there are if statements that (depending on the outcome of the ifs) sets function = True or function = False.

Now i want to (in another module) use an if statement to determine the result of the function (true/false).

The method i employed follows:


VB Code:
If classname.function = True Then'// DO STUFFElse'// DO SOMETHING ELSEEnd If


any help would be awesome, thanks.

Return In Function
When I do this:

VB Code:
return m_Position


it gives me a compile error: "expected end of statement" with "m_Position" selected.

How can I return a value then?

Function Return
Hello

I have a function that Downloads a file and returns a boolean if it was successful. At least that's what it's supposed to do.

The call for the function is:

Code:
DownloadFile "http://www.myweb.com/files/test.mdb"


I try to test if the download was successful with:

Code:
If DownloadFile = False Then
MsgBox "An error was encountered during the downloading of your file." & vbCrLf & _
"Check that you are connected to the internet and try again."
End If

This gives me the error message:
Parrameter not optional.

the function looks like this:
Code:
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean

Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)

If lngRetVal = 0 Then
DownloadFile = True
Else
DownloadFile = False
End If

End Function

And this:
Code:
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
ByVal szFileName As String, ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long


What am I doing wrong?

Thanks

David

PS. It gets the file just fine. I just can't verify it without actually looking in the dir to see if it's there or wait for the program crash when it isn't there.

Return Value Of A Function
I need a function that will return a predefined value based on what it is sent. So, if you send it a string of "A", it will return the integer "1". However, I also want it to do the inverse, so if I send it the "1", it will return an "A".

I am going to have many entries for this, so I'm looking for a relatively efficient way to do it, but the only idea I have is skecthed out below. Does anyone have a better way to do this?



Code:
Function (input as variant) as variant

Select Case input

Case 1: function = "entryA"

Case "entryA": function = 1

Case 2: function = "entryB"

Case "entryB": function = 2

...

End Select


Thanks.

Return Value From A Function?
I've asked this b4 and I forgot... so first off... does anyone know how I can find my way back to old threads I started? (I've erased all the email notifications)

How do you return a value from a function?

Return Function
Hello all,


Can anybody please give me a simple sample that how the return function would work...

Thanks.

How To Return A Value From A Function?
I have a problem with a function .. i need to return a value and i cant make
it work.. this is my code an a little explanation about what it should do.
hope you can help me


PHP Code:





 ALL THIS CODE IS IN A FORM----->

Function formatearFecha(ByRef fecha) As String

    Dim miAno, miMes, miDia

    miAno = Mid(fecha, 1, 4)
    miMes = Mid(fecha, 5, 2)
    miDia = Mid(fecha, 7, 8)

    fecha = miDia & "/" & miMes & "/" & miAno

End Function

Private Sub Form_Load()
Dim temp As String

    SOME CODE HERE....

    Do While Not rs.EOF()
    temp = formatearFecha(rs!fecha)
        msgbox temp
    rs.MoveNext
    Loop
End Sub 







Well the explanation: i retrieve a number from rs!fecha like 20030611 then
in the function i convert it to "date" format so i want the return value
something like "11/06/2003". the function works ok.. i mean it does what it
should do (trsnformthe number into date format) , but my problem is that in
the form load in the MSGBOX temp line it shows nothing, i mean .. temp
variable is NULL.. Why the the "fecha" variable is not passed to the
variable temp??? how do i return that value from the function? what im doing
wrong here??

Return Value Of Function
I am trying to fix a program that was made by some other people, so as to get it to work on our network settings.

A problem that I am running in to is when passing a string parameter to a function, I keep coming up with a Type Mismatch error.

My question is: If you have set a function to return a value, in this case a recordset, when calling the function do you have to assign it to a variable? The way that I see it below, is that the function is being called but the value being returned isn't being assigned anywhere.

The code is as follows:

txtSQL = "INSERT INTO TC (TC_ID, Active, Surname, Firstname) VALUES('" & id & "',0, '" & sName & "', '" & fName & "');"

callSQL (txtSQL)

Public Function callSQL(rs As String) As ADODB.Recordset
Dim TCList1 As ADODB.Recordset
Dim MsgText As String

MsgBox "In CallSQL function: SQL Statement = " & vbCrLf & rs
Set TCList1 = ExecuteSQL(rs, MsgText)

Set callSQL = TCList1

End Function

Return Value From Function?
ok i have a function that will make returnvalue = somthing

now this function is in a modual, how would i get the code from a form to return returnvalue?

cheers, Philly



Edited by - CopyrightPhilly2k4 on 11/26/2004 3:21:05 PM

Function - Return
Yo yo yo

In php, and in C++ I could write a function similar to

Code:
Function CheckFile()
    MyFile = Dir("path/to/file")
    If MyFile = "" Then
        //The file doesn't exist
        Return 1
    Else
        //If the file exists the function work properly
        Return 0
    End If
End Function


I know that that code is more then one language rolled into one but I hope some of you out there get the point

Now how can I do this in VB??

Thanks

How To Return From A Function In VB
If I want to return immediately in case a certain error happens, will this do it?

Function MakeDB()

if badA then

MakeDB = -1

return

endif

Or dont I need the return? Is it that as soon as you assign a value to the function name , it returns?

Return Value Function
Hi every one, this is valyndira again. Could anyone help me with example about return value function in VBA?
Thanks

#VALUE Return To A Function Array
When I return lots of data to an excel function array call - I get #VALUE error returned to all the cells.

I have a server app that can return lots a data to an excel function (eg: an array dimed arr(6, 1000)). When excel tries to write a big results array to the sheet i get the #VALUE error in all the cells of the function array.

any clues??

Return && Use An Array From A Function
I have several functions that return values and perform calculations that I want to use in both several different forms and reports (mainly the calculations, so if I change the code, all of the forms/reports will be using the changed code, instead of copying it from place to place.

I created a class module and I have functions like this:


Code:
Function employeeEmployeeStatus2(EmpID As String)

strSQL = "SELECT EmployeeStatus, CorportateHireDate FROM tblEmpData WHERE [Employee#]='" & EmpID & "'"

Set db = DBEngine.Workspaces(0).Databases(0)
Set rs = db.OpenRecordset(strSQL)

status = rs.Fields("EmployeeStatus")
hiredate = rs.Fields("CorportateHireDate") - Year(Date)

employeeEmployeeStatus2 = ?

End Function

If I just return a single value, everything works fine. But how do I return an array of the two "status" and "hiredate" variables, to save on coding and the amount of necessary queries.

Right now I have one query for each which doubles the amount the work necessary.

Function To Return Array
Is it possible for a function to take 1 integer and return an array of x amount of integers back.?

How To Return More Than 1 Variable From Function?
Hi,

I have a function that i parse 3 sets of variable:

Function LineLogging(j As Integer, LogStr As String, Dnum As Integer)




End Function

How do i return all these 3 variables back to the main routine before i exit this function?

Return Two Strings From A Function
Is it possible to return two or more strings, integers, etc from a function, other than when the variables are declared outside the function?

eg

Private Function Return(str1 as String, str2 as String)

End Function

It it possble for "Return" to contain two values, or is theere a different format for writing a function that returns two or more values?

How To Make A Function Return A Value
ive forgotton how to make a function return a value

eg

private function MyNumber
retval=a+4
end function

private sub timer1_go
if MyNumber>6 then end
end sub

Do I Have To Have A Return Type For A Function?
All the function is doing, is an action. Its not needed to return anything... so can I just leave it as:

Public Function RemoveServer(ServerName As String)

and then enter code i want to run here when the function is called?

thanks
-Angel

Return An Array From Function?
hi everybody,
I know, this might be a simple question to answer, but I'm a VB newbie and I haven't found anything on the web or VB-help.

I am trying the following:


Code:
Private Sub pSomeRoutine()

Dim aField(1 To 5, 1 To 7) As Variant

aField = fReturnArray

End Sub

'*----------------------------
Private Function fReturnArray() As Variant()

Dim aArray(1 To 5, 1 To 7) As Variant

'* some code to fill up array

fReturnArray = aArray

End Function
I keep getting the Error: "Can't assign to array". Can anyone help me on this? I'd be really glad!

Thanks for your help in advance!!

Have Function Return An Array
Code:
Public Function CryptIdentify(CryptTekst As String) As String()
Dim DekryptKeyPlacement As Byte
Dim Protokolltype As String
Dim DecryptTimes As String
Dim Result(1 To 3) As String
DekryptKeyPlacement = Val(Left(CryptTekst, 3))
Protokolltype = Mid(CryptTekst, DekryptKeyPlacement, 1)
DecryptTimes = Val(Mid(CryptTekst, DekryptKeyPlacement + 1, 2))
Result(1) = Protokolltype
Result(2) = DecryptTimes
Result(3) = "okey"
CryptIndentify = Result
Exit Function

'There is more to this, but that is only error related

Ok I'm making this encryption'ish kind of software, I have allready made this thing and it's rather large (.exe is 250k), so I have to modify the existing code, can't just replace this.

This functions purpose is to extract som information on how to decrypt from the encrypted text. I'm trying to extract this data (result (1 To 3)). I will call this function by

Code:
DecryptInfo = CryptIdentify(frmCrypt.Text1.text)
Here DecryptInfo is dim'ed as "DecryptInfo (1 To 3) as String" and Text1.text is the encrypted text provided by the user.

My goal is of course to have the content of Result(1 To 3) in DecryptInfo(1 To 3)

What am I doing wrong?

Wait For Function Return
All right then here is the problem. I need a function that will wait for another functionís return so I can check the return value with it. Sounds kind of simple and probable is but I donít even know where to start when it comes to making the code wait for a return, then execute depending on the results.

Function To Return More Than One Path
I am looking for a API that will like work like the browser for a folder but instead of returning one path it will return all the paths that are selected. The only time have ever seen the form I want is in the P2P software where a user will specify which folders will be shared with other. The form looks exactly like the BrowseForFolder but it has check boxes next to each path. Can anyone help me????

How To Get DLL Function's Arguments And Return Value
Hi, can anyone can tell me how to get the arguments and return value of a DLL. It is not an activex dll created in vb. I just have the dll and get the list of function on dependency viewer to get the function list, but I cannot use the function in vb coz it just give the names.

I used the:
<vb>
Private Declare Function CFLGetLast Lib "C:CFL32.DLL" () As Long
</vb>

It is possible to the correct arguments and return value???

thanks in advance...

Function Return Codes
The documentation i have for the shellexec() function from shell32.dll states that the return code will vary. After trying different things to affect the function's return, i noticed different codes, but i still did not comprehend the computer's understanding of these events - the error codes would just show up as numbers. The documentation does not number these codes, but just gives them fancy constant-looking names such as ERROR_FILE_NOT_FOUND.

How does one go about mapping the numeric code to its constant name?

Function To Return Object?
Im wanting to make an ActiveX DLL, But I want to be able to use the same object all the way through. Heres an example.


* Code:
Public Function Navigate(oURL As String) As String
    Dim oHTTP As Object
    Set oHTTP = CreateObject("winhttp.winhttprequest.5.1")
    oHTTP.Open "GET", oURL, False
    oHTTP.Send
    Navigate = oHTTP.ResponseText
End Function


Now, This would work fine, But everytime I run the function, It would be a new object every time. I tryed this, But it doesnt work;


* Code:
Public Function Init() As Object
    Dim oHTTP As Object
    Set oHTTP = CreateObject("winhttp.winhttprequest.5.1")
    Init = oHTTP
End Function

Public Function Navigate(oHTTP As Object, oURL As String) As String
    oHTTP.Open "GET", oURL, False
    oHTTP.Send
    Navigate = oHTTP.ResponseText
End Function


Though, When I call the Init, It errors.
Any ideas on how to have Init() return the oHTTP object?

Return Recordset In A Function
I am trying to pass a record set back thru the function (e.i. tempvar = getusers(1)). I want a Variant/Object/Recordset but i am getting a Variant/Object/Fields. Here is my code...what am i doing wrong.

Code:

Public Function GetUsers(Optional sid) As Recordset
Set t = New ADODB.Recordset
If IsNumeric(sid) Then
t.Open "select * from [user] where site = " & sid, cs
Else
t.Open "select * from [user]", cs
End If
Set GetUsers = t
t.Close
End Function

Function Procedure-return More Than One Value
Hiya,
I can use a Function procedure to retun a value as shown below, is there a way to return more than one value

a = 11
b = 88
c = myfunc(a, b)

Text1.Text = c


Public Function myfunc(a, b)

myfunc = a + b
End Function

I've looked on net but cant find any answers.
Thanks
Evan.

Getting At Function Return Values
Can I get a function to return multiple values?

If I write:

Dim myAgentID as Long
myAgentID = mFullAppDlg.ReturnAgentID(myAgentID)

And, in the class file that has the function it looks like:

Public Function ReturnAgentID(ByRef AgentID As Long) As Boolean
AgentID = 1234
End Function

How do I get at the value of AgentID?

myAgentID is returning the boolean.

Cheers

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