|
Well, gee, there's a tidbit that might have been worth mentioning. In that case, I have no idea, beyond that you'd use the Microsoft Tools for Office. Perhaps you should modify your subject line so it actually relates to the question, and so you might attract the attention of someone who knows the answer.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi, relatively new to vb
trying to get various parts of a db into an array
all examples so far are a bit too vague for me to follow
what i need is a more detailed (ie tutorial) example of how to
i so far have an array of strings and am trying to get items in a db to populate said array
any links to tutorials or good examples in vb .net would be much appreciated
-N
|
|
|
|
|
You would fill a data table from your database, then iterate over it using the Rows property, and then pull out the strings from each row to fill your array.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
what is the coding i would use? i have infact no relevant code for this module of my program, thus haven't supplied any
ive been struggling for a while now
array(1) = me.dataset1.table("",x,y) - where x and y are rows and columns
is there something similar / what do i have to do to make this work?
do remember that i am new to vb and programming in general
-N
|
|
|
|
|
You will get all the examples that you need if you search MSDN for the terms that Christian mentions.
1) fill a data table
2) iterate the Rows property
doing it this way will also help you to remember how to do it (at least it does for me), with the added benefit that you discover additional stuff along the way.
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.”
|
|
|
|
|
Hi, All
Is there any way to decompile a .ocx file which is compiled by VB6.0? If not, is there any way to extract the files that this ocx is composed of? that is to say, if the ocx file contains some .frm files, some .bas files and so on, can we extract these from the one ocx file?
Thanks
Best regards
Wei
|
|
|
|
|
No, I don't believe so.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I cannot figure out why this doesn't work. Everythign says it should... I'm trying to see if a datagridviewrow contains DBNUll
'first = IIf(TypeOf _row.Cells(1).Value Is DBNull, 0, CDec(_row.Cells(1).Value))
'second = IIf(TypeOf _row.Cells(2).Value Is DBNull, 0, CDec(_row.Cells(2).Value))
'final = IIf(TypeOf _row.Cells(3).Value Is DBNull, 0, CDec(_row.Cells(3).Value))
I GET ERRORS!!!
But if I do this, not only is it ugly as heck but it works!!
If (TypeOf _row.Cells(1).Value Is DBNull) Then
first = 0
Else
first = _row.Cells(1).Value
End If
If (TypeOf _row.Cells(2).Value Is DBNull) Then
second = 0
Else
second = _row.Cells(2).Value
End If
If (TypeOf _row.Cells(3).Value Is DBNull) Then
final = 0
Else
final = _row.Cells(3).Value
End If
Why?!?! I'm so angry. I have tried everything from
IsDBNull(value)
to
value Is DbNull
value Is DbNull.Value
to
value is typeof(DbNull)
Its just frustating.. am I doing something wrong here or is this just a flaw?
|
|
|
|
|
Yah I knew I used it somewhere, try
mvLogID = IIf(IsDBNull(oRow("LogID")), 0, oRow("LogID"))
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
No luck. I'm not trying to find if a row is null, just if a cell is null
first = IIf(IsDBNull(_row.Cells(1)), 0, CDec(_row.Cells(1).Value))
second = IIf(IsDBNull(_row.Cells(2)), 0, CDec(_row.Cells(2).Value))
final = IIf(IsDBNull(_row.Cells(3)), 0, CDec(_row.Cells(3).Value))
Using the name instead of the index doesn't work either.
Still get "Conversion from DBNull to type Decimal is not valid"
|
|
|
|
|
Can I have my foot back now please I was testing against a DATAROW.
Try, you are testing the cell, it will always be there. And here is your foot
first = IIf(IsDBNull(_row.Cells(1).Value), 0, CDec(_row.Cells(1).Value))
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Lol
Still no luck though. Here it is:
(All of it)
For Each _row As DataGridViewRow In dgvGrades.Rows
Dim first, second, final As Decimal
' ********* This doesnt not seem to work but technically it should **************
' ********* Must be a FLAW in VB.net :-) lol ************
'first = IIf(TypeOf _row.Cells(1).Value Is DBNull, 0, CDec(_row.Cells(1).Value))
'second = IIf(TypeOf _row.Cells(2).Value Is DBNull, 0, CDec(_row.Cells(2).Value))
'final = IIf(TypeOf _row.Cells(3).Value Is DBNull, 0, CDec(_row.Cells(3).Value))
first = IIf(IsDBNull(_row.Cells(1).Value), 0, CDec(_row.Cells(1).Value))
second = IIf(IsDBNull(_row.Cells(2).Value), 0, CDec(_row.Cells(2).Value))
final = IIf(IsDBNull(_row.Cells(2).Value), 0, CDec(_row.Cells(3).Value))
Dim _average As Decimal = (first + second + 2 * final) / 4
For Each _sRow As DataGridViewRow In dgvStudents.Rows
If _row.Cells(0).Value Is Nothing Then
Exit For
Else
If _row.Cells(0).Value = _sRow.Cells(0).Value Then
dgvAverage.Rows.Add(New Object() {_sRow.Cells(2).Value.ToString() + " " + _sRow.Cells(1).Value.ToString(), _average.ToString(), CalculateGrade(_average), IIf(_average > 59, True, False)})
Exit For
End If
End If
Next
Next
The funny thing is (well not so funny) is that I can do this:
If IsDBNull(_row.Cells(1).Value) Then
MessageBox.Show("IT IS NULL!")
End If
AND IT WORKS! its the same thing!
|
|
|
|
|
you said "you get errors". what error are you getting?
btw...not sure if you meant to do this but you are testing cell 2 again and then useing cell 3
final = IIf(IsDBNull(_row.Cells(2).Value), 0, CDec(_row.Cells(3).Value))
'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
|
|
|
|
|
The error is it can't convert dbnull to decimal. It shouldn't be trying because it's supposed to make it 0 if it was dbnull. Yeah I didn't mean to do that I just changed it so much trying to get it to work I messed that up
|
|
|
|
|
I have seen that somestimes checking for dbnull in an IIF doesn't always work. try breaking it out into a normal IF/Else statement.
'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
|
|
|
|
|
Well I know that it works fine with a bunch of if then statements.
I was trying to figure out if it was something I was doing why the IIf wasn't working. But its starting to look more like a flaw with VB.net. Using the IIf statements looks much cleaner and less code to me. But if it just won't work with comparing DBNull values.. then what can I do lol
|
|
|
|
|
ya it's a bug...
you can get the same effect by writing a function that will act like the IIF so you'll get the clean look but the function will use the full if/then/else...
't = true part of iif / e = else part of iif
public function MyIIF (b as boolean, t as object, e as object) as object
you can of course overload that to do type-safe checks
public function MyIIF (b as boolean, t as string, e as string) as object
public function MyIIF (b as boolean, t as integer, e as integer) as object
etc
'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
|
|
|
|
|
Ok Thanks for your help
|
|
|
|
|
If you're using VB9 there is an overload for the If keyword that solves this problem.
Instead of IIf try just using If
|
|
|
|
|
When using IIF both the true and the false portions are evaluated before the IIF test is done.
using the If construct only the true portion is evaluated after the IF test is done and the false portion is never evaluated if the test is true.
|
|
|
|
|
Hi
In my app i have to read thousands of lines of data written in a
text file.
I have saved the lines previously.
The size of text file is 50 MB.
My problem is that it takes a lot of time to read that.
If i save the lines in a database, would the 'reading' be faster?
TheMrProgrammer
http://www.icbse.com/2009/funny-exam-answers-school-students
http://download.cnet.com/TheCalcMan/3000-2094_4-10958266.html
|
|
|
|
|
Hi,
I very much doubt reading 50MB of data is taking very long, it should be possible to do that in say 1 second. If your app is slower at it, it probably is due to what it is you do with the data, such as adding it to some of the GUI controls. Tell us more, and show some relevant code.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi Luc,
Thanks for reply.
Yes I do more than reading.
I read the file.
Dim s$ = my...readalllines(myfile.txt)
There are sentences separated by # which I transfer in an array
so that one sentence get into one element of array
using simple code of 6 lines.
This operation I do in the variable s.
that's all I do.
The size of the testing file is 10 MB and it takes about 4 min and 24 s
The size of real file is nearly 50 MB.
So what do you suggest now?
TheMrProgrammer
http://www.icbse.com/2009/funny-exam-answers-school-students
http://download.cnet.com/TheCalcMan/3000-2094_4-10958266.html
|
|
|
|
|
Prankur Rusia wrote: So what do you suggest now?
Huh? The same as I suggested some 10 hours ago. You haven't given any new facts.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi
I got the answer to my question.
The file gets read quickly but the sorting in to the array takes time.
There one thing I would like to ask you.
The basic purpose of this is to search within the text file for a word.
As there can be multiple occurrences of that word I first put the sentences,
sentence by sentence, into an array.
Then I search the array element by element to find the word by looping through the array.
Now if I use the database, I would have access to the data already sorted
sentence-wise.
Then I just need to loop the database to search.
Now I wanted to ask you, if I use the above defined process, will it be
faster?
Is the algorithm I am following is an efficient one?
I know you are a busy man.
But please spare a minute and tell me.
Thanks.
TheMrProgrammer
http://www.icbse.com/2009/funny-exam-answers-school-students
http://download.cnet.com/TheCalcMan/3000-2094_4-10958266.html
|
|
|
|