Results 1 to 11 of 11

Thread: noob here need helo on declareing

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    12

    noob here need helo on declareing

    what i want to do is declare
    VB Code:
    1. arnold as string
    and then say
    VB Code:
    1. arnold = (App.Path & "\Data\Students\Class 1\Green\Arnold.ini", "Student", "4")
    but i want is so if i need to use it any where in the program i can just put arnold if you see what i mean.
    there are going to me 32 names used so is there a way to do it in a module? cheers gareth

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: noob here need helo on declareing

    What's that? looks like paramaters to a Sub without the Sub name. Are you trying to read data from an INI file?

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    12

    Re: noob here need helo on declareing

    yes i am i have that all working but the ReadIniValue is not there because i just want to say some where along the line ReadIniValue arnold and then it will look at the ini file that has been declared with arnold .

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: noob here need helo on declareing

    maybe something like this? Using a UDT

    VB Code:
    1. Private Type INIData
    2.     sPath As String
    3.     sSection As String
    4.     sLine As String
    5. End Type
    6.  
    7. Dim Arnold As INIData
    8.  
    9. Private Sub Command1_Click()
    10.     ReadINI Arnold
    11. End Sub
    12.  
    13. Private Sub Form_Load()
    14.     Arnold.sPath = App.Path & "\Data\Students\Class 1\Green\Arnold.ini"
    15.     Arnold.sSection = "Student"
    16.     Arnold.sLine = "4"
    17. End Sub
    18.  
    19. Private Function ReadINI(sData As INIData) As String
    20.     'Here is where you pass in the data to your INI read function
    21.     'Just an example
    22.     'ReadIniValue sData.sPath, sData.sSection, sData.sLine
    23. End Function
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    12

    Re: noob here need helo on declareing

    thanks thats a nice bit of code! its allmost what im looking for. i just want arnold to = (App.Path & "\Data\Students\Class 1\Green\Arnold.ini", "Student", "4") so if i did ReadIniValue or WriteIniValue i could just put arnold and i could do that on any form in the program

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: noob here need helo on declareing

    I would do it this way
    VB Code:
    1. Public Function ReadINI(sSection As String, sPath As String, sName As String) As String
    2.     'Here is where you pass in the data to your INI read function
    3. End Function
    4.  
    5. Private Sub Command1_Click()
    6. ReadINI "Student", App.Path & "\Data\Students\Class 1\Green\", "Arnold"
    7. End Sub
    I would also have a drop down combo box containing all the names that you need. I would have another drop down combo contains the INI file section names. With that, your user could selection what section and what name, so you would do
    VB Code:
    1. Private Sub Command1_Click()
    2. ReadINI, cboSection.Text, App.Path & "\Data\Students\Class 1\Green\", cboName.Text
    3. End Sub

  7. #7

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    12

    Re: noob here need helo on declareing

    wow man that is sweet just how i want it but sorry to be a pain and i would love it if you could do this for me: i have 6 classes an to houses green and yellow using the last bit of code you wrote and combo dropdown boxes could you please write the could! i really appreciate what you written so far

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: noob here need helo on declareing

    Do you know how to add items to a combo box or a listbox?

  9. #9

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    12

    Re: noob here need helo on declareing

    yer i just trying to think how to do that

  10. #10
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Oregon
    Posts
    643

    Re: noob here need helo on declareing

    This one is easy!

    1) Make a Module

    2) Declare your string like this: Global Arnold as String

    3) On your main form that loads up first, under Load or Activate, put in your arnold = whatever code and your set.. Anywhere in the program you can say Arnold = whatever, or whatever = arnold, or use it however you wish.

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: noob here need helo on declareing

    Quote Originally Posted by gareth_2007
    yer i just trying to think how to do that
    Use the Additem method
    VB Code:
    1. Combo1.Additem "Whatever"

Posting Permissions

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



Click Here to Expand Forum to Full Width