|
Hi,
you can append text like so myTextBox.Text+=newTextToBeAppended;
(chances are you want to append an Environment.NewLine too).
when you always append text, you probably will want to have a "clear" button too.
BTW: if you change the ListBox.SelectionMode you can allow the user to select several consecutive
or non-consecutive items in the listbox (using the shift and control keys where appropriate).
Then the doubleclick handler could combine all selected items (ListBox.SelectedItems) using
a simple foreach loop and string concatenation, saving the user a lot of double-clicks (and foregoing
the need for a clear button).
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I use this codes but no changes
Private Sub ListBox1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDoubleClick
Dim newTextToBeAppended = Environment.NewLine
**** TextBox7.Text = combobox.Text & "in (select sifrazbroja" & vbCrLf & _
"from zbroji" & vbCrLf & vbCrLf & _
"where" & vbCrLf & _
"cast(case when cijena1 = " & TextBox1.Text & " then '1' else '0' end as int)"
TextBox7.Text += newTextToBeAppended
**** I want this data as many time as I double_click the listbox
|
|
|
|
|
OK,
these are the two most popular mistakes that would lead to the updated text not showing
or not showing right away:
1.
say your form class is called myForm, you have more than one myForm instance; the first one
got created and is visible on the screen, the second or later one(s) is/are created inside
the button click handler, listbox double click handler, or where ever, and that is the one
you are modifying, but since you never Show or ShowDialog it, it does
not show at all, hence you don't see the changes.
If this is the case, the right thing to do is NOT to create more than one myForm instance, and to make sure it is the first and only instance that gets modified. If more than one form class is involved, you need to either pass one form to the other (a bad idea), pass one control to the other form (a bad idea), install a public method to update a form's Control from the outside (acceptable) or a delegate and an event (best practice). There are several articles on this subject here at CP.
2.
you are performing a lengthy operation on the GUI thread, say you modify the textbox text,
then count the number of files on your disk, then exit the lisybox double click handler; as
long as the handler is busy, whatever changes it applied to the GUI Controls will not show;
the GUI will update when the handler exits though.
If this is the case, the right thing to do is NOT to perform lengthy operations on the GUI thread;
for good GUI behavior handler execution should never last longer than say 30 msec. If it
takes more, or could take more, the job must be delegated to a separate thread (a real thread,
one from the ThreadPool, a BackgroundWorker, whatever); be careful then to not let it touch
GUI Controls directly, you would need Control.InvokeRequired/Control.Invoke for that. If you need this, look it up in MSDN and read some CP articles on the subject.
Hope this helps.
PS: next time you show some code, please use the "code block" button below the edit window,
it will insert PRE tags which give a monospaced font, a background color and foremost they
preserve all formatting.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
' in ListBox1_DoubleClick
Me.TextBox1.Text = Me.TextBox1.Text & Me.ListBox1.Text & vbCrLf
Samir R. Ibrahim
modified on Saturday, February 7, 2009 1:38 PM
|
|
|
|
|
|
purva shekdar wrote: i need a code in visual basic 6 tat helps me to search all types of files in all drives of my computer
So, what are you waiting for?? Start writing it! Noone here is going to do your job for you.
Or, did you mean to ask a specific question about a problem you're having with YOUR code??
|
|
|
|
|
purva shekdar wrote: pls help me as soon as possible
Sure.
1 - stop using VB6, it was always crap and has been unsupported for a long time
2 - buy a book on VB.NET
3 - learn to use google and MSDN
4 - now the job is easy.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
Noone is just going to hand you a completed project. YOU have to write it yourself. We can help with that part, but as for doing your job for you, forget it.
|
|
|
|
|
Hi Dave
I am new in forum, and I am still learning vb.net
I know vb6 (good) and I am Professional in Foxpro (VFP)
I am an active member on many foxpro forums, and I have my own blog for foxpro
I am telling that to ask a question
in foxite forum, if someone ask this question I can give him
#1 already posted message to his answer.
#2 a link to web page that solve his answer.
#3 a link to my blog that I had already write a document on this question.
Is the rule in here that you don't answer question posted if the person who post
the question did not make some effort?
I am with "make some effort, then post your problem if you get stuck"
Can you point please to #1 #2 #3 which are acceptable and which are not?
Sorry If I ask to much, I Just want to make sure I don't make wrong when posting Q or A
TIA
Samir R. Ibrahim
|
|
|
|
|
Samir Ibrahim wrote: Is the rule in here that you don't answer question posted if the person who post
the question did not make some effort?
Yes. There's just WAY too many "questions" asking for code. There's too much copy'n'paste coding going on in the world and too many "students" who just want their assignments done for them.
So, when someone asks for code, it's chances are VERY high that it's not to help them write their own code.
You can put up any answer you want. I've gotten so tired of "programmers" want their code written for them, they get the standard answer of "if you want code, WRITE IT!"
|
|
|
|
|
|
I think the other point is also that VB6 is no longer supported and you are doing NEW development in it. You originally asked for a solution, not guidance and to top it of you consider it urgent. It is only urgent to YOU.
These points will insure you get no help from the forum which is here to help, not supply code. Seriously, trash the VB6 and move to .net NOW
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If you insist on using VB6, Google for "FileSystemObject". The logic is "recursive", so you may want to Google that too.
And yes, you asked for the code, not a push in the right direction.
|
|
|
|
|
hi all
i want to import calendar from app such as outlook and hotmail in to my program, which is a template of Diary
does any know how i can go about this or how i can create this in vb.net
|
|
|
|
|
Use the APIs/COM objects
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
i don't want to import it permanetly,it only for, when the user logs in their account in my program and want to view their calendar from hotmail for example,
|
|
|
|
|
I need to populate a combobox with a list of the past 20 years.
So I get
2009
2008
2007
...
I have
For x As Integer = Date.Now.Year - 20 To Date.Now.Year Step -1<br />
form.YearFromComboBox.Items.Add(x.ToString())<br />
Next
but the loop never runs in code. What am I doing wrong please (apart from being in charge of a computer )?
|
|
|
|
|
The first problem with the code, as posted is that your list will be reversed.
i.e. it will give
1989
1990
1991
........
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Of course. I've been staring at this darn thing for far too long today.
Thanks.
|
|
|
|
|
kanchoette wrote: I've been staring at this darn thing for far too long today
I know that feeling.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Dim X as integer
for x = Cint(date.Now.year) to (Cint(Date.Now.Year)-20) step - 1
YearFromCoomboBox.items.add(x)
next
|
|
|
|
|
Curious why you are using CInt for this? The Year property already is an Integer.
Or you should be consistent and convert every value:
Dim x As Integer
For x = CInt(Cdate(CDate(Date).Now).Year) to (CInt(CDate(CDate(Date).Now).Year) - CInt(20)) step CInt(-CInt(1))
YearFromCoomboBox.items.add(CStr(CInt(x)))
Next
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
For i As Integer = 0 To 20
MsgBox(Now.AddYears(i * -1).ToString("yyyy"))
Next
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Don't call the Now method repeatedly, that is bad practice. In this specific case it's quite unlikely, but the reason is that the value returned by Now changes, so you can get different values from one call to the next. Get the value into a variable, and use the variable repeatedly.
When you loop from a higher value to a lower, you have to put the higher value first in the For statement:
Dim year As Integer = DateTime.Now.Year
For x As Integer = year To year - 20 Step -1
form.YearFromComboBox.Items.Add(x.ToString())
Next
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|