text files and combo boxes in visual basic
Here's what i've got so far:
Code:
Open "filename here" For Input As #1 |
Re: text files and combo boxes in visual basic
Ok, first of all, you didn't say what exactly you want to do. But it seems you want to fill Combo-Boxes from a Text-File.
Well, combo1[1] is nothing really, it only describes a combobox. You must say WHAT you want to do. I.e. Code:
Input #1, tempString Uh, and 2 obligatory tipps for good programming style: Dont use "as #1". You usually go like this: Code:
Dim FileNum as Integer The other thing is, I personally found, that opening files for Binary usually works best, then plain-reading strings, and parsing them. But ok, you probably need to get used to it and make your own experience... |
Re: text files and combo boxes in visual basic
Square brackets in Basic? That's something I haven't seen yet.
|
Re: text files and combo boxes in visual basic
Quote:
|
Re: text files and combo boxes in visual basic
Quote:
|
Re: text files and combo boxes in visual basic
arrays use square brackets.
and thanks for the help, it's working ok now. |
Re: text files and combo boxes in visual basic
Quote:
|
Re: text files and combo boxes in visual basic
Wowowo NO!!!
Sorry people, I CANNOT understand how I -- always in favour of VB -- got this wrong, after only 8 weeks of Java course (and arrays only since 1 week). Just as SI said: IN VB, you gotta use () for arrays. [] won't do it in VB. I tried it: Code:
Dim heya(1 To 100) As Integer ' DOES work |
Re: text files and combo boxes in visual basic
Quote:
|
Re: text files and combo boxes in visual basic
Fair enough. It's been ages since I've done anything in VB :p
|
Re: text files and combo boxes in visual basic
Iirc square brackets in VB are only used for variable names that normally are not allowed:
Code:
Dim [Spaces are bad!] As String |
Re: text files and combo boxes in visual basic
Quote:
|
Re: text files and combo boxes in visual basic
Quote:
|
Re: text files and combo boxes in visual basic
just checked, you're right. Damn java and its corrupting square brackets.
|
Re: text files and combo boxes in visual basic
another quick combobox question: how do I use the selected value?
|
Re: text files and combo boxes in visual basic
combo.text I think
or was it combo.value ? |
Re: text files and combo boxes in visual basic
combo.text seems to work, cheers.
|
Re: text files and combo boxes in visual basic
Usually it should behave like a "normal" listbox, PLUS it's got the additional text-property for combo style.
So, you'd get the selected value like this (out of my head): Code:
combo1.List(combo1.ListIndex) I'm almost tempted to say RTFM, but I since it's Christmas and not that bad, well... |
Re: text files and combo boxes in visual basic
whilst this thread is here, can someone tell me how to hand variables across from one form to another?
|
Re: text files and combo boxes in visual basic
Quote:
My guess is that you can set the global variables that are in the form module. Like: Code:
' Form module frmTest Code:
' somewhere else Also, let me know if you know how to open multiple instances of the same form (the same form, opened multiple times at the same moment). |
Re: text files and combo boxes in visual basic
Well, I'm not quite sure if SI's method would work, as I'm afraid you cannot use "dim" in a form module, but have to use "private" instead -- i.e. no public variables there.
I myself would work with modules (.bas-files) anyway. And do all the stuff from there. Have a Sub Main() where the project starts (Project, Properties, Startup Method, -> Sub Main). Then in this sub, you load and show all your forms etc. To "pass" variables from Form to Form you'd use a global variable, declared in your module. But all the important and non-form-specific stuff happens inside that module then anyway. How you create multiple instances of a form I don't know, but I can guess: Create and desing a form, let's say frmMain. And then somewhere, call Code:
Dim MyForms(1 to 100) as Form |
Re: text files and combo boxes in visual basic
SI, found this:-
Procedure-level variables are created with a Dim statement placed right in the procedure where it's going to be used. The value of a procedure level variable cannot be accessed outside it's procedure. When the procedure finishes (End Sub or End Function), the variable is destroyed and memory allocated to the variable is released. Module-level variables are created with a Private statement in the general declarations section of a Form or code module. The value of the module level variable is available to every procedure in that module. Memory allocated to the module-level variable is not destroyed until the module is Unloaded. Global variables are created with a Public statement in the general declarations section of a Form or code module. The value of a Global variable is available to any procedure, in any Form or code module. Memory allocated to a Global variable is not released until your program shuts down. |
Re: text files and combo boxes in visual basic
also, i think that if you want to load a form many times, can't you just do
Code:
dim no_of_forms as integer |
Re: text files and combo boxes in visual basic
another question: how do i make a table, without using excel or anything else like that?
|
Re: text files and combo boxes in visual basic
Quote:
Quote:
There can't be a "Public" statement in the code of a form. Try it. Not allowed. Only in modules... Quote:
I'd recommend MS GridLine Control. It's an OCX and should be installed on every system nowadays anyway. Also it come with the Visual Basic runtimes. Just have a look around at those MS Common Controls. "Project, Components..." |
Re: text files and combo boxes in visual basic
i tried the public in a form and it seems to work ok :p, thanks for the table thing
|
Re: text files and combo boxes in visual basic
Ok ok I am quite sorry ^^
I tried it as well now, and public SEEMS to be allowed for varialbles and subs/functions, but NOT for constants or external functions (from dlls, using "declare", e.g. winAPI). Also you cannot have public arrays or strings of fixed length in forms... |
Re: text files and combo boxes in visual basic
true, but if you want to move text or arrays then just use text files or binary files or whatever.
|
Re: text files and combo boxes in visual basic
Quote:
That's really bad. You should never do that. Or I got it wrong. But even if it's for messages between foreign forms (i.e. of different apps), you could use DDE or Callbacks or Shared Memory. |
All times are GMT +1. The time now is 02:10. |
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018