|
Store your used questions to a HashTable, then when you want to ask a new question check whether it already exists there.
|
|
|
|
|
That depends on how you store the questions and how you pick the questions to ask.
You can keep a list of unused questions, and remove it from the list once it's used. You can keep a flag in each question that determines if it has been used or not. You can store an identifier or reference of the used questions to compare against. You can prepare a list of questions in the order that they will be asked and just loop through the list.
---
single minded; short sighted; long gone;
|
|
|
|
|
I suggest adding them to a list and deleting them after they are used. You can add them as strings to a string collection.
Dim Questions as system.collections.specialized.stringcollection<br />
<br />
Dim UsedQuestion as system.collections.specialized.stringcollection<br />
<br />
dim ranQuestion as new random<br />
<br />
Dim CurretnQuestion as string = questions.item(ranquestion.next(-1, questions.count +1 )<br />
<br />
questions.remove(indexof(CurrentQuestion))<br />
<br />
UsedQuestions.add(currentQuestion)
In this way, you never risk repeating a question.
Posted by The ANZAC
|
|
|
|
|
Hi all! I have a VBA question. I know what the error means when doing a Windows("Workbook Name").Activate or a Sheets("Sheet Name").Select. It means that the object does not exists? Well, I am pretty sure.
But this is really strange to me. There is one Workbook named EndOfMonth.xls. The macro is from this workbook. There is also one worksheet in the workbook named EndOfMonth.
The Sheets("EndOfMonth").Select command is where I am getting the error. But I copied and pasted this from a recorded macro and the sheet is there.
Why would this happen?
Thanx in advance!
Jude
|
|
|
|
|
I have an application that I'm writing to load a spreadsheet, massage the data, and then populate a sql server table. This code works great except the cell for a date field in the spreadsheet is saying it's dbnull but when you look at the spreadsheet and the date is there and valid.
Dim oConn As System.Data.OleDb.OleDbConnection = Nothing
Dim ds As System.Data.DataSet = New System.Data.DataSet, dsRow As Data.DataRow = Nothing
Dim oComm As System.Data.OleDb.OleDbDataAdapter = Nothing, dsCol As Data.DataColumn = Nothing
Dim oAdj As Adjuster = Nothing, oState As New Adjuster.State
Try
oConn = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source='c:\temp\adjusterlicense.xls';" & _
"Extended Properties=Excel 8.0;")
oComm = New System.Data.OleDb.OleDbDataAdapter("select * from [CZ Adjuster Licenses$]", oConn)
oComm.Fill(ds)
For i As Int16 = 8 To ds.Tables(0).Rows.Count - 1
dsRow = ds.Tables(0).Rows(i)
.
.
.
'col 9 = 10/31/07
'col 10 = AJ40008453
For iState As Int16 = 9 To ds.Tables(0).Columns.Count - 1 step 2
'' why is IsDBnull(dsRow(9)) = True when IsDBNull(dsRow(10)) = False
Next
Next
What's interesting is that if I export this file into a comma delimited file, the date is there.
Any help would be greatly appreciated...
Nathan
|
|
|
|
|
Has the column been established as a type that wont accept the date by that point?
Cleako
|
|
|
|
|
The first row of the spreadsheet is blank which I thought maybe causing the problem. I put a dummy date in the date column so that it would be looked at as a date but it didn't help.
|
|
|
|
|
hi,
i have to add a button save in the dataGrid in order to save the changes i made in the checkBoxs for each row,
syntax Help plz for the button , the detecting of current row in DataGrid
vb.net 2003
thanks
|
|
|
|
|
I found all of this information out for myself from Google and trial and error, Im glad to help but we cant tell you every step of the project.
Anyway, this is another template column with a button and a command to call OnClick. Unless you are talking about a Editable datagrid and then you should Google for that.
Cleako
-- modified at 10:16 Wednesday 14th February, 2007
|
|
|
|
|
Hi..
I want to know how to extract the zip file using vb.net. If any one know please help me.
Thanks.
Navas.M
|
|
|
|
|
|
When it comes to coding I think I am too paranoid about input and I would like some feedback to help me rid myself of the obsession (Im not talking about input validation but rather Null Reference Exceptions or formatting strings that need to be non-blank).
I almost always perform 2 checks on a string and include a trim no matter what.
If strValue IsNot Nothing AndAlso strValue.Trim <> "" Then
I have read some things saying that I should probably use strValue.Length > 0 . What I am curious about is should I always perform the .Trim or is if strValue = " " considered 0 length?
Also on DB items I usually perform 3 checks.
If dr.Item("ColumnName") IsNot DBNull AndAlso dr.Item("ColumnName") IsNot Nothing AndAlso dr.Item("ColumnName").ToString.Trim <> "" Then
How much of that is necessary?
This may seem ridiculous but I guess Im tired of doing so much if I dont need to.
Thanks!
Cleako
|
|
|
|
|
cleako wrote: I almost always perform 2 checks on a string and include a trim no matter what.
If strValue IsNot Nothing AndAlso strValue.Trim <> "" Then
If you are using .NET 2.0 this can be shortened to
If Not String.IsNullOrEmpty(strValue) Then NOTE: It doesn't trim the string first.
cleako wrote: What I am curious about is should I always perform the .Trim or is if strValue = " " considered 0 length?
" " is considered to be not empty. An empty string contains zero characters.
cleako wrote: If dr.Item("ColumnName") IsNot DBNull AndAlso dr.Item("ColumnName") IsNot Nothing AndAlso dr.Item("ColumnName").ToString.Trim <> "" Then
How much of that is necessary?
It depends on what you are checking for. You could make it more efficient by assigning the result to a local variable first then it doesn't have to repeatedly look up the value for the column.
Personally, if you are having to trim whitespace off the strings all the time I'd tread that as a data error and would try to clean the data at source first. NOTE: if you are using a CHAR column in the database then it will always space pad the value. I'd recommend moving to VARCHAR unless you have a compelling reason to stay with CHAR (e.g. A legacy system you share the database with would freak if it wasn't space padded)
|
|
|
|
|
Hey,I'm new for the group, I have a little problem with menuItems.
I'm developing a pocket pc application in vb.net (compact framework), so I have a indefinited number of "Inherits System.Windows.Forms.Control" and
only one "Inherits System.Windows.Forms.Form" alias the MainForm.
In this MainForm I have created the menu and I have added the menuItems visible for all the "Controls".
I want personalize the menuItems and render visibles some Items in some controls and not in other.
which is the best way to improve my code?
I've tryed to disabled my menuItems with the fragment "me.menuItem.disabled = true" in maiform, and it give back correcty disabled the component in every forms, but i I want render it disabled in an other form what I should do?
thank to everybody!
daniele castrovinci
|
|
|
|
|
What is form handle in .net and at what time we will create and use them?
|
|
|
|
|
.NET is a wrapper on Win32, so a handle, is basically the same thing it's always been. You never create one, it's just something that every form has, because it is, at the end of the day, a Win32 window.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You may use the handles of forms when using API commands.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hi all,
How could I take the values of cells in the dataGrid and use them outside the dataGrid
e.g:
i have TimeIn & TimeOut for a certain person during one month (or more or less)
i need to calculate the total hours ' in the specified time and view the total in a textBox
syntax help (examples) is also needed
thank you
|
|
|
|
|
There are really 2 choices here. You can grab the values out the datagrid, which means you would probably want to use the OnItemDataBound event and calculate the hours for each row as it is added or you can look at the datasource you are providing and get the values from there.
For the OnItemDatabound event you can do a case statement like this (this is from memory so forgive me if it isnt exactly correct) -
Select Case e.Item.Type<br />
Case Item<br />
'Calculate from cell contents and get a TimeSpan object<br />
ts = Convert.ToDateTime(e.Item.Cells(#).Text).Subtract(Convert.ToDateTime(e.item.Cells(#).Text)<br />
<br />
txtTotalHours = ts.TotalHours<br />
End Select<br />
Something along those lines, I hope that helps!
Cleako
|
|
|
|
|
Hi, i will try to solve ur problem. The values u entered i mean the employee values that was stored in a table right, again if u want to retrive that values and display on data grid right, if yes means the values u stored in data grid while retriving then create a local variable that supports the perticular data type on which u are operating, with the index of the recordset suppose TimeIn t1 and TimeOut t2 then t2 - t1 for every loop of that perticular employee and keep adding the result to the local variable at last when the record set is empty then assign the value to the textbox out side the grid,I think u may confused but i did it, if u want more information abt this then mail to me
|
|
|
|
|
thak you both Rahul Appu & cleako
srour_costavo@hotmail.com
this is my email so if u have msn add me and we can discuss more online
10x a lot
|
|
|
|
|
how could I convert a value in the dataGrid to string in order to use it outside the grid?
|
|
|
|
|
You either need to do something like OnItemDataBound because that will let you access each row or you will need to know the row index and cell number in order to access the .Text property which returns a string. I have found that many times though it will return a & nbsp; (spaced so it will show up) value so I almost always do a .Text.Replace("& nbsp;", "") on the value to make sure I dont have that HTML space.
Check out http://www.datagridgirl.com/[^], there you will find many datagrid answers.
Cleako
|
|
|
|
|
I'm a newbie at VB.Net so please don't smite me for this stupid question
I have a form with various buttons eg. movies, music, setups etc.... and i would like a windows explorer window to open up to the relevent directory on my HDD. Example if i clicked "Movies" it would open "D:\Movies" in a normal windows explorer window.
The only problem with my plan is that I don't know the code to make this happen. so could anyone help me??
Thank You
|
|
|
|
|
Process.start will take a path, and open it, I believe.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|