Professional Web Applications Themes

Equating a String & Integer Variable - ASP.NET General

I am constructing a string in my program and then trying to use it to get the value of an integer variable whose label looks like that string. I can't figure out how to do it. For example: Dim aXYZ As Integer = 5 Dim myString As String Dim myResults As Integer myString = "aXYZ" myResults = SomeFunction?(myString) What I want is for myResults to equal 5 using "SomeFunction?" as shown above. How do I do that? In actuality, I have a large dataset (7,000 rows) where I count the number of occurrences of approximately 100 items sprinkled throughout the ...

  1. #1

    Default Equating a String & Integer Variable

    I am constructing a string in my program and then trying to use
    it to get the value of an integer variable whose label looks like
    that string. I can't figure out how to do it. For example:

    Dim aXYZ As Integer = 5
    Dim myString As String
    Dim myResults As Integer

    myString = "aXYZ"

    myResults = SomeFunction?(myString)


    What I want is for myResults to equal 5 using "SomeFunction?" as
    shown above. How do I do that?

    In actuality, I have a large dataset (7,000 rows) where I count
    the number of occurrences of approximately 100 items sprinkled
    throughout the rows. I have 100 integer variables structured
    similar to aXYZ in my example above. As I do my counting in the
    dataset, I use the following code:

    For I = 0 To cntSpring - 1
    mMajor = DataSet.Tables("Spring03").Rows(I).Item("MAJOR1")
    Select Case mMajor
    Case "ACT" : sACT += 1
    Case "AED" : sAED += 1
    Case "ANP" : sANP += 1
    Case "ARH" : sARH += 1
    etc.
    End Select
    Next

    ....where cntSprint is the number of rows in the dataset named
    "Dataset" and Spring03 is the name of one of the databases making
    up the dataset.

    Once I come out of the For...Next loop above, I have 100 integer
    variables (e.g., sACT, sAED, etc.) that represent the
    distribution of their occurrence in the dataset. In another part
    of my program, I am trying to construct a string like "sACT" and
    do something to it so that I get the associated integer number
    that came out of the For...Next loop. I'm baffled.


    Thanks
    Roger





    Roger Lord Guest

  2. #2

    Default Re: Equating a String & Integer Variable

    Hi,

    What about using System.Collection.HashTable. you can add to the hash
    table the keys (e.g., sACT, sAED, etc.) ) and values. then you can
    retrive the values by the key.

    Setting :

    For I = 0 To cntSpring - 1
    mMajor = DataSet.Tables("Spring03").Rows(I).Item("MAJOR1")
    if OHashTable.ContainsKey(mMajor)
    OHashTable(mMajor) += 1
    else
    OHashTable.Add(mMajor,1)
    end if
    Next

    Getting :

    myString = "aXYZ"

    myResults = OHashTable(myString)

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  3. #3

    Default Re: Equating a String & Integer Variable

    Natty,

    Your suggestion wasn't exactly what I had in mind; but, the
    bloody thing worked! Thanks for teaching me something new.

    Roger

    ---------------------------------------

    "Natty Gur" <nattydao2com.com> wrote in message
    news:u6x06OFQDHA.1748TK2MSFTNGP11.phx.gbl...
    Hi,

    What about using System.Collection.HashTable. you can add to the
    hash
    table the keys (e.g., sACT, sAED, etc.) ) and values. then you
    can
    retrive the values by the key.

    Setting :

    For I = 0 To cntSpring - 1
    mMajor = DataSet.Tables("Spring03").Rows(I).Item("MAJOR1")
    if OHashTable.ContainsKey(mMajor)
    OHashTable(mMajor) += 1
    else
    OHashTable.Add(mMajor,1)
    end if
    Next

    Getting :

    myString = "aXYZ"

    myResults = OHashTable(myString)

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!


    Roger Lord Guest

Similar Threads

  1. string to integer
    By Mark Fenbers in forum Macromedia Flash Data Integration
    Replies: 10
    Last Post: May 23rd, 08:08 AM
  2. check string rep's integer
    By sinister in forum PHP Development
    Replies: 7
    Last Post: November 24th, 09:27 AM
  3. ado xtra - integer variable in sql-string
    By janosch webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 2
    Last Post: October 14th, 10:18 PM
  4. php array problem string to integer
    By Sébastien in forum PHP Development
    Replies: 0
    Last Post: August 3rd, 06:17 AM
  5. HowTo check if my String is a Number (Integer) ?
    By Craig Deelsnyder in forum ASP.NET
    Replies: 0
    Last Post: July 27th, 11:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139