Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2004, 09:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default Getting 2 values from a Function

Hi all.

Do anyone know if it's possible to assign 2 different values to 2 variables from a function and make them global? Like :
Code:
Function SeperateFields(m_Fields)
  Dim intEndOfField1
  intEndOfField1 = InStr(m_Fields, ", ") 
  m_Field1 = mid(m_Fields, 1, intEndOfField1 -1) 
  m_Field2 = mid(m_Fields, intEndOfField1 +2, Len(m_Fields))
End Function
SeperateFields("gasga, fgsagas")
  Response.Write(m_Field1 & "<br />")
  Response.Write(m_Field2 & "<br />")
 - mega
__________________
- mega
Aspiring JavaScript Ninja
 
Old June 17th, 2004, 07:51 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use the Split() function:

myFieldsArray = Split("gasga, fgsagas",", ")
-----------------------------------------^ Notice the extra space

response.Write(myFieldsArray(0) & "<br />"))
response.Write(myFieldsArray(1) & "<br />"))

 
Old June 17th, 2004, 08:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

Hi Napoleon Solo.

I'm using the function in a Class so I had some other alternatives than just plane old VBS. I have overcome it by making Private properties for the fields' variables and then I could assign a value to each property:
Code:
  Private Property Get Field1()
    Field1 = m_Field1
  End Property
  Private Property Let Field1(p_Data)
    m_Field1 = p_Data
  End Property

  Private Property Get Field2()
    Field2 = m_Field2
  End Property
  Private Property Let Field2(p_Data)
    m_Field2 = p_Data
  End Property
    Private Sub SeperateFields(m_Fields)
      Dim intEndOfField1
      intEndOfField1 = InStr(m_Fields, ", ") 
      m_Field1 = mid(m_Fields, 1, intEndOfField1 -1) 
      m_Field2 = mid(m_Fields, intEndOfField1 +2, Len(m_Fields))
      Field1 = m_Field1
      Field2 = m_Field2
    End Sub
 ' and in a function I call
Call SeperateFields(Fields)
But your suggestion could have been used just as well and with lesser code.

 - mega





Similar Threads
Thread Thread Starter Forum Replies Last Post
Can two forms share values within a function mat41 Javascript 8 March 4th, 2007 11:31 PM
C# equivalent function to VB chr for values > 128 relaytest49 ASP.NET 2.0 Professional 0 May 24th, 2006 10:08 AM
roundup function conflict with null values mjuliao Access 2 October 30th, 2005 05:16 PM
Passing Date, String values in ASP Function. rupen Classic ASP Basics 2 July 6th, 2005 09:42 PM
EXEC function not returning values aingalsbe PHP How-To 0 June 1st, 2004 10:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.