Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Retriving data to put into a combo box!!!

GammelGammel Member Posts: 34
Hi I am making a webpage manager and I have gotten so far as to add the data to a text file in a format such as this:

"Programmers Heaven","www.programmersheaven.com","A great site"
^
Quick Name

I want to be able to, when I open the program open the text file and put all of the Quick names into a cbo box and then select a name from the list so it brings up the rest of the details like the url and desc.
here is the code I have so far.

--------------------------------------------------------------------Private Sub cmdAdd_Click()
Open "C:webpages.txt" For Append As #1
Write #1, Trim(txtQckNme.Text), Trim(txtAddress.Text), Trim(txtDescription.Text)
Close #1
txtQckNme.Text = "" 'Quick Name
txtAddress.Text = "" 'The URL
txtDescription.Text = "" 'Webpage Desc
End Sub
--------------------------------------------------------------------
Private Sub Form_Load()
Open "C:Webpages.txt" For Input As #1
'????????????????????????????????????????
'????????????????????????????????????????
'????????????????????????????????????????
'????????????????????????????????????????
Close #1

End Sub
--------------------------------------------------------------------
I would like a very basic solution to this cause I just started programming. I don't want to use anything other than visual basic and notepad. Any help would be appreciated. Thanks

Brett

Comments

  • MalcolmMalcolm Member Posts: 828
    [b][red]This message was edited by Malcolm at 2002-7-30 22:19:8[/red][/b][hr]
    [b][red]This message was edited by Malcolm at 2002-7-30 22:17:49[/red][/b][hr]
    [b][red]This message was edited by Malcolm at 2002-7-30 22:17:14[/red][/b][hr]
    : Hi I am making a webpage manager and I have gotten so far as to add the data to a text file in a format such as this:
    :
    : "Programmers Heaven","www.programmersheaven.com","A great site"
    : ^
    : Quick Name
    :
    : I want to be able to, when I open the program open the text file and put all of the Quick names into a cbo box and then select a name from the list so it brings up the rest of the details like the url and desc.
    : here is the code I have so far.
    :
    : --------------------------------------------------------------------Private Sub cmdAdd_Click()
    : Open "C:webpages.txt" For Append As #1
    : Write #1, Trim(txtQckNme.Text), Trim(txtAddress.Text), Trim(txtDescription.Text)
    : Close #1
    : txtQckNme.Text = "" 'Quick Name
    : txtAddress.Text = "" 'The URL
    : txtDescription.Text = "" 'Webpage Desc
    : End Sub
    : --------------------------------------------------------------------
    : Private Sub Form_Load()
    : Open "C:Webpages.txt" For Input As #1
    : '????????????????????????????????????????
    : '????????????????????????????????????????
    : '????????????????????????????????????????
    : '????????????????????????????????????????
    : Close #1
    :
    : End Sub
    : --------------------------------------------------------------------
    : I would like a very basic solution to this cause I just started programming. I don't want to use anything other than visual basic and notepad. Any help would be appreciated. Thanks
    :
    : Brett
    :

    There would be a few ways to do this. Heres one.

    Put this code in the declarations section of your form module.

    [code]Private QuickNames() As String
    Private URL() As String
    Private Description() As String
    Private Count As Long[/code]

    Put this code in the sub where you want to load the combo items:

    [code]Open "C:Webpages.txt" For Input As #1
    Do While EOF(1) = false
    ReDim Preserve URL(0 To Count) As String
    ReDim Preserve Description(0 To Count) As String
    ReDim Preserve QuickNames(0 To Count) As String
    Input #1, QuickNames(Count), URL(Count), Description(Count)
    Combo1.AddItem QuickNames(Count)
    Count = Count + 1
    Loop
    Close #1[/code]

    Then in the click event of the combo put this code. This code assumes that you are using two textboxes named txtURL and txtDescription to show the appropriate information.

    [code]
    Dim lngIndex As Long
    lngIndex = Combo1.ListIndex
    txtURL.Text = URL(lngIndex)
    txtDescription.Text = Description(lngIndex)[/code]









  • GammelGammel Member Posts: 34
    Malcom you are my new god!!!!!!
    It was easy to understand as well.
    Thanks.

    *Brett dances around the room on a high!!!!*


  • GammelGammel Member Posts: 34
    Hey malcom or anyone
    Just a few more things

    How do I make it so I can click a button called cmdRefresh to basically restart the program???

    And how to I make an error box come up if they click search without choosing a quickname.

  • GammelGammel Member Posts: 34
    : Hey malcom or anyone
    : Just a few more things
    :
    : How do I make it so I can click a button called cmdRefresh to basically restart the program???
    :
    : And how to I make an error box come up if they click search without choosing a quickname.
    :
    Also eveytime I run it an error comes up saying

    Compile Error
    Member already exists in an object module from which this object derives

    It points to
    Private Count as Long
    in my declarations

    Help me please.
    Its stopping me from making it an exe

  • [DAMN][DAMN] Member Posts: 26
    : : Hey malcom or anyone
    : : Just a few more things
    : :
    : : How do I make it so I can click a button called cmdRefresh to basically restart the program???
    : :
    : : And how to I make an error box come up if they click search without choosing a quickname.
    : :
    : Also eveytime I run it an error comes up saying
    :
    : Compile Error
    : Member already exists in an object module from which this object derives
    :
    : It points to
    : Private Count as Long
    : in my declarations
    :
    : Help me please.
    : Its stopping me from making it an exe
    :
    Errormessage!!!!
    : If combo1.Text = "" Then
    msgbox "Message", vbInformation + vbOKOnly, "Information"
    Exit Sub
    End If

    [DAMN]

  • MalcolmMalcolm Member Posts: 828
    : : Hey malcom or anyone
    : : Just a few more things
    : :
    : : How do I make it so I can click a button called cmdRefresh to basically restart the program???
    : :
    : : And how to I make an error box come up if they click search without choosing a quickname.
    : :
    : Also eveytime I run it an error comes up saying
    :
    : Compile Error
    : Member already exists in an object module from which this object derives
    :
    : It points to
    : Private Count as Long
    : in my declarations
    :
    : Help me please.
    : Its stopping me from making it an exe
    :
    :


    Try changing count to something else like ItemCount. But don't forget that you'll need to change all occurances of Count in the code I gave with the new variable name.


  • GammelGammel Member Posts: 34
    : : : Hey malcom or anyone
    : : : Just a few more things
    : : :
    : : : How do I make it so I can click a button called cmdRefresh to basically restart the program???
    : : :
    : : : And how to I make an error box come up if they click search without choosing a quickname.
    : : :
    : : Also eveytime I run it an error comes up saying
    : :
    : : Compile Error
    : : Member already exists in an object module from which this object derives
    : :
    : : It points to
    : : Private Count as Long
    : : in my declarations
    : :
    : : Help me please.
    : : Its stopping me from making it an exe
    : :
    : :
    :
    :
    : Try changing count to something else like ItemCount. But don't forget that you'll need to change all occurances of Count in the code I gave with the new variable name.
    :
    Thanks man I changed it to Spurkle
    lol
    Brett

  • Andre YoungAndre Young USAMember Posts: 0

    _______ \ http://forcoder.org \ free video tutorials and ebooks about ( PL/SQL, R, JavaScript, Scratch, MATLAB, Python, C#, Go, PHP, C++, Visual Basic, Swift, Objective-C, Perl, Delphi, Ruby, C, Assembly, Visual Basic .NET, Java VBScript, Lisp, Kotlin, F#, Julia, Scheme, Scala, LabVIEW, Apex, ML, Hack, Bash, Transact-SQL, Erlang, Clojure, Lua, ABAP, Crystal, Alice, FoxPro, COBOL, Dart, Awk, Logo, Ada, SAS, Rust, D, Prolog, Fortran ) ___________

Sign In or Register to comment.