|
I am confused. You have CarsNamesLBX and CarsNamesLBox, and now CarsNamesBox. Which is it? Are you sure they are instantiated at some point and not disposed before getting to this code?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
LOL, sorry 'bout that, I had changed the name of the list box to conform to my naming convention. I should have made comments on the post about the changes. Have you figured out yet what is causing the exception to be thrown? I have used step-into, step-over, etc in debug mode but I can't figure out what the cause of the problem is. Thank you in advance for your time.
|
|
|
|
|
Honestly, if you're stepping through the code, and you can't work out what object does not have a value, then you should seriously re-evaluate this whole programming thing.
Something is set to Nothing, which means you've not given it a value. Work out what it is by checking the values of all the variables in use in the line that blows up. Stop saying things like 'I tried what Christian said and it didn't work'. What I said is correct, so if you can't make it work then post the code, so we can help you. You're iterating over the items collection, when there is a property that gives you what you want, the selected value. If the SelectedValue throws the same exception, then the control itself is probably null, but again, you have to step through the debugger and work that out.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
ASPnoob wrote: For i = 0 To CarsNamesLBox.Items.Count - 1
ASPnoob wrote: SELECT CarID, Model From CarsTB where Make = 'CarsNamesLBox.Items(i).Text'",
Oh, I didn't even spot that ( I think the other poster did ).
SELECT CarID, Model From CarsTB where Make = '" & CarsNamesLBox.Items(i).Text & "'",
I am pretty sure this is what the code looked like when I first saw it, actually. If you further mangle your code, post it in a reply, not by editing the post. Change it to
SELECT CarID, Model From CarsTB where Make = '" & CarsNamesLBox.SelectedItem.Text & "'"
add a check to see if CarsNamesLBox.SelectedItem = Nothing, and get rid of the loop. That's what I told you to do in the first place. Beyond that, if you're getting this exception, you need to go into the debugger, set a breakpoint on the line, and type things like CarsNamesLBox and CarsNamesLBox.SelectedItem and CarsNamesLBox.SelectedItem.Text, until you find the property that has a value of Nothing, which is what is causing your error.
And, in future, be aware that things can be uninitialised, and write code that checks, so it can fail gracefully.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
This is related to the formatting, not the topic, of your message.
I am preparing an article on copying code snippets from a CodeProject message board to
Visual Studio; seems there are no problems when the browser used is FireFox, Safari, ...
but often problems arise when using Internet Explorer.
One of the factors is the tags that are present inside the < PRE> </PRE> block.
In your message the lines are separated by <br> tags; most other messages have
just regular newlines.
Could you please tell me how you get that, i.e. what tools you use, and how you go
about it. Thanks in advance.
|
|
|
|
|
Regarding what line or lines in my message do you have questions?
|
|
|
|
|
it is about how you post code in a message:
which browser ?
any other additional tool ?
do you add tags such as CODE or PRE or BR ...
thanks
|
|
|
|
|
Yes, I use all three tags and I use firefox most of the time. I usally would write my messages in note pad then copy and paste it in the text area of forum or I would browse to my file.
|
|
|
|
|
|
how can make a word pad like application in vb.net using rich text box
|
|
|
|
|
Just start out with something simple, like the Richtext box, and start adding in functionality that you would like to have.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
i have already add the rich textbox and the other things
my problem is
the printing of the contents of the rich text box
i have a fair idea about that i just want to make a printdocument and i don't know how to do that
and the other problem is the ruler and the bars of the ruler how to make one of them
|
|
|
|
|
Though I understand you may be doing this project in VB since you are asking in the VB forum, here is an article in C# that maybe helpful for you in your project
http://www.codeproject.com/csharp/eRichTextBox.asp[^]
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
|
You're welcome.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
To print the content of richtextbox, try code posted here:
http://support.microsoft.com/default.aspx?scid=kb;en-us;811401
|
|
|
|
|
|
I would to compare the value from the certain column, row of 2 different text files. I have already stored into them to 2d array. Any idea how to start from scratch so that i can compare them? It involves the complicated for loop or do while loop.
|
|
|
|
|
I don't see what the question is. If you have them in a 2D array, then use the right indices to compare the values that need comparing ? Perhaps you need to explain more.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
For example:
For File A.txt and B.txt, I have already stored the value from certain row and column of A.txt and B.txt into 2 D array by using the do while loop. For A and B, they got their own do while loop.
If i compare the value outside the do while loop, the 2d array would get the undefined value. They cannot be compared at all.
If I put both of the A and B in One do while loop, it will become complicated.
|
|
|
|
|
So, create your arrays THEN use those arrays to lookup the values you want to compare.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Q1/If this is the path to save an open Excel file running in the background
xlSheet.SaveAs("c:\My Path\tk" & Format (Me.MonthCalender1.SelectionStart, "yyyyMMdd") & ".xls")
How would I open a file using the MonthCalender1 (Change-Date) as the trigger to determine the name? e.g. "tk20070727.xls" ?
Q2/ Having opened the file (running invisable in the background), how can I pull the data from a cell to a variable?
Q3/ How do I close the invisable running .xls file in runtime?
|
|
|
|
|
So how many times are you going to post the same question(s) in one day? Yes, it's considered very rude.
I don't do Office Interop, so my experience with it is VERY limited.
But, I'd image you would find the Open method on a Workbooks collection. You'd have to pass it the complete path to the file you want to load. It looks like you already know how to generate the filename you need.
Pulling data from the cells would probably involve something about a Range object with, maybe, a Cells collection that holds a bunch of cells, and possible a Value property of each Cell .
There's a ton of examples out there. All you have to do is Google for something like "vb.net Excel workbooks", or "vb.net excel Range object", "vb.net excel retrieve cell values".
|
|
|
|
|
Thanks Dave for you compassion and understanding. I hope you have a wonderful day and everything goes the way you'd like it too.
|
|
|
|
|
You have to manualy release COM object to kill the excel process running in the background.
Say your Excel.Application object is myApp . Then use this:
<br />
myApp.Quit()<br />
System.Runtime.InteropServices.Marshal.ReleaseComObject(myApp)<br />
System.GC.Collect()
--------------------------------
txtSignature
|
|
|
|