|
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
|
|
|
|
|
I can do that in a fast way with or without a database.
And everyone can come up with a slow implementation with or without a database. Getting it slow with a database is harder to achieve, since there is less code to mess with.
FYI: de database has to read the data from disk too, and search your string too, so why would it really be faster?
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.
|
|
|
|
|
Dear Members,
I have a datagridview in windows form. In this grid one column is datagridviewcheckboxcolumn. when i select the first checkbox and i click a save button in toolstrip it will not work. But the same code in command button it is worked. Please check the following code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim arr As New ArrayList
Dim en As New TestEnity
en.Name = "name1"
arr.Add(en)
en = New TestEnity
en.Name = "name2"
arr.Add(en)
dgTest.DataSource = arr
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each row As DataGridViewRow In Me.dgTest.Rows
Dim checkBoxCell As DataGridViewCheckBoxCell = TryCast(row.Cells("dgvSelected"), DataGridViewCheckBoxCell)
If checkBoxCell IsNot Nothing Then
Dim checked As Boolean = CType(checkBoxCell.Value, Boolean)
If checked Then
MessageBox.Show("Row : " & row.Index & "Checked")
Else
MessageBox.Show("Row : " & row.Index & "Not Checked")
End If
End If
Next
End Sub
Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click
For Each row As DataGridViewRow In Me.dgTest.Rows
Dim checkBoxCell As DataGridViewCheckBoxCell = TryCast(row.Cells("dgvSelected"), DataGridViewCheckBoxCell)
If checkBoxCell IsNot Nothing Then
Dim checked As Boolean = CType(checkBoxCell.Value, Boolean)
If checked Then
MessageBox.Show("Row : " & row.Index & "Checked")
Else
MessageBox.Show("Row : " & row.Index & "Not Checked")
End If
End If
Next
End Sub
End Class
Public Class TestEnity
Dim _Name$
Public Property Name()
Get
Return _Name
End Get
Set(ByVal value)
_Name = value
End Set
End Property
sree
|
|
|
|
|
ToolstripMenu's Forms will be your MDI-Parent, and datagridview is in mdi_child, So you have to call by form5.My_Save()
So put your save-codes inside a sub and call it from mdi_parent as I gave.
|
|
|
|
|
I use a webservice to import the xml into a ms access database, and interop code is not working.
This is my code so far, but it is not working properly.
im strConnection As String
Dim objDataSet As New DataSet()
Dim objConnection As OleDbConnection
Dim objAdapter As OleDbDataAdapter
Dim intI As Integer
Dim ds As New DataSet
Dim streamRead As New System.IO.FileStream("C:\NTB100514_07_22_2009_225551.xml", System.IO.FileMode.Open)
ds.ReadXml(streamRead)
streamRead.Close()
If ds.Tables.Count > 0 Then
strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & "c:\PC Auditer.accdb"
objConnection = New OleDbConnection(strConnection)
objConnection.Open()
objAdapter = New OleDbDataAdapter()
Dim cb As New OleDbCommandBuilder(objAdapter)
For intI = 0 To ds.Tables.Count - 1
If ds.Tables(intI).Rows.Count > 0 Then
DataGridView1.DataSource = ds.Tables(intI)
objAdapter.SelectCommand = New OleDbCommand("SELECT * FROM [" + ds.Tables(intI).TableName + "] ", objConnection)
objAdapter.Fill(ds, ds.Tables(intI).TableName.ToString)
objAdapter.UpdateCommand = cb.GetUpdateCommand()
objAdapter.Update(ds, ds.Tables(intI).TableName.ToString)
End If
Next
objConnection.Close()
End If
In my access database all the primairy keys and relationships are defined. The first time (intI=0) the update command works well, but the second time (intI=1) iI get an error.
Kind regards,
Jurgen
ps: I am a beginner, so excuse me if my code is lokking so nice.
|
|
|
|
|
What is the error ? Have you stepped through in the debugger to see what is happening ? What line has the error ?
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 Christian,
The error is in line: objAdapter.Update(ds, ds.Tables(intI).TableName.ToString)
"Missing the DataColumn 'ID' in the DataTable 'Shares' for the SourceColumn 'ID'"
I don't have a datacolumn 'ID' in my table Shares. I think it has to do with the
primairy key and referential integrety. The previous table 'SOS' has a column ID (primairy key)
which has a relation with the column 'ID-Share' from table 'Shares'.
Kind regards,
Jurgen
|
|
|
|
|
There are four steps to it, which are defined below:
Step 1:
Click on External Data ribbon, go to the "Import" section and click on XML file option.
Step 2:
Use the browse option to go to the location where the XML file is located from which data needs to be imported. Click Open and then OK.
Step 3:
Access will scan through the file and display the structure of the table to be created. The Import Options includes the following options, namely Structure Only / Structure & Data / Append data to existing table. In our process we will choose the option of both structure and data.
Step 4:
If you plan to import the same file agian in the future then you can check the box "Save Import Steps".
Now you can double click on the table that is created and would be able to see the structure and the data in it i.e. imported from the XML file.
Eliza
http://www.mindfiresolutions.com/[^]Cheers,
Eliza
|
|
|
|
|
From Form-Load() I have query like the following
dim Query1 as string="Select * from My_Table"
Dim Da1 as SqlDataadapter,Ds1 as new Dataset,dtb1 as new datatable
con.open()
Da1=new sqlDataAdapter(Query1,con)
Da1.Fill(Ds1)
con.close()
dtb1=Ds1.Tables(0)
After some data's were added to the table "My_Table", and now from Combobox-Click(), I want to update it again..
Anybody can point me?
Thanks
|
|
|
|
|
Make your query a routine:
Private sub GetData()
dim Query1 as string="Select * from My_Table"
Dim Da1 as SqlDataadapter,Ds1 as new Dataset,dtb1 as new datatable
con.open()
Da1=new sqlDataAdapter(Query1,con)
Da1.Fill(Ds1)
con.close()
dtb1=Ds1.Tables(0)
' Update your UI here...
End Sub
then call this from both the FormLoad(...) event and the ComboBox._Click(...) event.
<edit -="" while="" this="" code="" is="" crap,="" it="" will="" work.="" make="" sure="" you="" are="" doing="" the="" correct="" cleanup="" etc.="">
Private Sub FormLoad(...)...
GetData()
End Sub
Private Sub ComboBox_Click(...)...
ComboBox.Items.Clear()
GetData()
End Sub
I don't speak Idiot - please talk slowly and clearly
I don't know what all the fuss is about with America getting it's first black president. Zimbabwe's had one for years and he's sh*t. - Percy Drake , Shrewsbury
Driven to the arms of Heineken by the wife
modified on Saturday, July 25, 2009 12:43 PM
|
|
|
|
|
ThankYou
|
|
|
|
|
Can anyone guide me to solve this problem.
i create a setup of outlook VSTO add-in. This setup is not working in Both Winodow XP and Vista.
So my friend suggest me that to write code in Outlook Share Add-In. I again create share Add-in Setup
and try to run in both machine. But Unfortunately it is not working in XP. And working successfully in Vista.
Can any one guide me which file needed to add in XP so my Share Add-in Work on XP also
Regards
DC
|
|
|
|
|
Please be patient - posting your question twice on the same page in the forum is SERIOUSLY bad form. People will answer, when and if they have the inclination.
In case you didnt notice, but it is the weekend in most of the world and most CP members do have a life outside of this site.
I don't speak Idiot - please talk slowly and clearly
I don't know what all the fuss is about with America getting it's first black president. Zimbabwe's had one for years and he's sh*t. - Percy Drake , Shrewsbury
Driven to the arms of Heineken by the wife
|
|
|
|
|
when I save date it save as for example 06:48 A.M
but i want it save such as 18:48
please help me
|
|
|
|
|
Tell me you are NOT saving your dates as strings (varchar()). A date should be saved as a DATETIME datatype, NEVER, EVER, EVER use text datatypes to save your dates.
If you store your date as Datetime then the format you DISPLAY the data is up to you, look at the datetime type.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi All,
I am sending mail by using my application and Opening Text File.
So antivirus shows my application to Spyware. my confution is that outlook and other software also send mail but they are now showing in spyware category.
So how to create my application to antivirus avoider. Because my application is not working any wrong activity.
and when i try to open log file. Antivirus shows it trying to use shell execution command.
So please help me how to resolve it.
If you can think then I Can.
|
|
|
|
|
You have to change what your code is doing, what access it requests of files, where the files it reads live, etc, until you satisfy the anti spyware program that you're not doing anything wrong.
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.
|
|
|
|