|
Friends, i want to ask that is there a way to auto fix columns in a data grid, I mean if i have to display just two columns in data grid and datagrid size is larger than two columns width.. they just r displayed on left and rest of the grid remain empty.. how can i FILL data grid with only two coloumns.. ? Should i have to chage the columns width manually.. but what if there are three columns sometimes to display?
looking to here from u soon
|
|
|
|
|
I dp not know open, read , write in vb.net., and the other thing is that, how create a data in vb.net, this is the line of code which i tried, but does not work at all. textbox1.databindings.add("text", data1, "Name")
tell me the steps how to do this things please who ever can tell me.
|
|
|
|
|
|
HI,
I have a problem with VB.net’s DataGrid. I wish to have two header rows with the bottom header nested in the top header eg The top header is Monday with Lunch and Dinner as headers underneath
____________________________
| __ Monday__ | __ Tuesday__ |
|----------------------------- |
|Lunch | Dinner |Lunch | Dinner |
|----------------------------- |
| ****| *****| ****| ***** |
|----------------------------- |
| ****| *****| ****| ***** |
|----------------------------- |
Cheers Shane
|
|
|
|
|
im a beginner using VB.net and im trying to display an autonumber in a vb.net form
ive got a person table (in access) with the fields person_ID, person_firstname, person_surname. The person_ID field is an autonumber.
Ive connected the database to a vb form (not web form). On the form ive added an Add button.
(So what im trying to achieve is when u click on the add button, the next availalbe autonumber should appear)
but i dont know how to do it. Every site ive looked at says to set autoincrement to 1. I have no idea how to do this, so could someone give me a step by step guide on how to do this, or send me an actual example of how it works
my email is cheetahshot@hotmail.com
thx
|
|
|
|
|
The autonumber won't be assigned until the record is updated. What you could do is when your Add button is clicked, add the new record to the database with blank fields. This will give you your autonumber. Then, bind your fields to the new record using the autonumber you got back as the key to make sure your only modifying that record. But, of course, this depends on the restriction imposed by the database, such as fields being tags as not being able to hold NULL values, or fields requiring values within a certain range, ...
RageInTheMachine9532
|
|
|
|
|
how could i add a blank line, then attach the records to that line? Would you be able to explain that a bit more?
|
|
|
|
|
Is this a Windows Forms app or a Web App? Are you displaying the records in the database with a DataGrid? What does your Add button do?
There is no one reference that will teach you how to do this. There are many different method to accomplish what your trying to do. Search the web for articles specific to the objects and statements your trying to use and Amazon for ADO.NET/VB.NET books. There are dozens of books on the subject and they can explain everything in much better detail that any article can.
But for here, post the code you're using so we can take a look at what your doing and make some recommendations. Normally, your app shouldn't care about the Autonumber until AFTER the new data is posted to the database, not before. This is because of data validation reasons and consistancy of the ID field.
RageInTheMachine9532
|
|
|
|
|
I'm having a problem accessing my database from a network drive. I'm using the Jet 4 connection to try and access the database. It tests fine, but when I debug, it can't find the database. I can put the database on my desktop's hard drive and set up the connection and it works fine, but not when it's on the network drive. If anyone could help me, I'd appreciate it. Thanks.
|
|
|
|
|
Does that account your using have access to the share on the other machine?
I should ask, does the account have the proper rights to the share? You can't use just read-only. The account must have read and write access...
RageInTheMachine9532
|
|
|
|
|
I am trying to get 5 random numbers between the numbers of 1 to 50 using vb.net. This is what I came up with so far:
Dim Array(4) As Integer
Dim Counter As Integer
For Counter = 0 To 4
Array(Counter) = CInt(Int((49 * Rnd()) + 1))
Next
Array.Sort(Array)
lbl1.Text = Array(0)
lbl2.Text = Array(1)
lbl3.Text = Array(2)
lbl4.Text = Array(3)
lbl5.Text = Array(4)
This code actually works but the thing is that it can pick the same number twice. I need all 5 numbers to be different. How can I achieve this?
Please help and thanks in advance.
Beginner in VB.NET
|
|
|
|
|
I've not put this in a compiler to check the syntax, so appologies in advance if I'm mistyped something. Here is a solution.
On each iteration the previous values are checked with the current random value and if they match a new random number is generated, this checking continues until there are no matches, at which point the value is put in the array and it moves on to the next element, like in your original code.
Dim Array(4) As Integer
Dim Counter As Integer
Dim CheckCounter As Integer
Dim Current As Integer
Dim IsOkay As Boolean
For Counter = 0 To 4
IsOkay = True
Do
Current = CInt(Int((49 * Rnd()) + 1))
For CheckCounter = 0 to Counter-1
If Current = Array(CheckCounter)
IsOkay = False
End If
Next
Loop While IsOkay = False
Array(Counter) = Current
Next
Array.Sort(Array)
lbl1.Text = Array(0)
lbl2.Text = Array(1)
lbl3.Text = Array(2)
lbl4.Text = Array(3)
lbl5.Text = Array(4)
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event
|
|
|
|
|
Yes with a few added lines which are in bold:
Dim Array(4) As Integer<br />
Dim Counter As Integer<br />
Dim CheckCounter As Integer<br />
Dim Current As Integer<br />
Dim isOkay As Boolean<br />
For Counter = 0 To 4<br />
isOkay = True<br />
Do<br />
Current = CInt(Int(49 * Rnd()) + 1)<br />
For CheckCounter = 0 To Counter - 1<br />
If Current = Array(CheckCounter) Then<br />
isOkay = False<br />
Exit For<br />
Else<br />
isOkay = True<br />
End If<br />
Next<br />
Loop While isOkay = False<br />
Array(Counter) = Current<br />
Next<br />
Array.Sort(Array)<br />
lbl1.Text = Array(0)<br />
lbl2.Text = Array(1)<br />
lbl3.Text = Array(2)<br />
lbl4.Text = Array(3)<br />
lbl5.Text = Array(4)
I had to add the else isOkay = true because with your origional code, once isOkay was set to false it was stuck in the loop. Which has solved my problem.
Thanks again
Beginner in VB.NET
|
|
|
|
|
Britnt7 wrote:
had to add the else isOkay = true because with your origional code, once isOkay was set to false it was stuck in the loop
Sorry, about that. I just typed it in the text box on the web site and it looked okay. Just goes to show that testing is really important.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event
|
|
|
|
|
Is it possible to pull from a list or array (1-50) so when the number is chosen, it is taken out of the list or array? Therefore it cannot be chosen again for the next random number. I didn't want the same number to be chosen twice at all.
That is what I intended to do but your code works as well. Just curious.
Beginner in VB.NET
|
|
|
|
|
Britnt7 wrote:
Is it possible to pull from a list or array (1-50) so when the number is chosen, it is taken out of the list or array?
Yes, of course. Here is an example (It is a complete console application if you want to test it)
Module Module1
Sub Main()
' Randomize the random number generator so it
' produces different results each time
Randomize()
' Declare variables
Dim Array(4) As Integer
Dim Counter As Integer
Dim PossibleValues As ArrayList
Dim Current As Integer
Dim Index As Integer
' Build a list of possible values
PossibleValues = New ArrayList(50)
For Counter = 0 To 49
PossibleValues.Add(Counter)
Next
' Populate the Array of random values, removing
' each from the list of PossibleValues as they
' get used
For Counter = 0 To 4
Index = Int(PossibleValues.Count * Rnd())
Current = CInt(PossibleValues(Index))
Array(Counter) = Current
PossibleValues.RemoveAt(Counter)
Next
'Print out the Array
Array.Sort(Array)
Console.WriteLine(Array(0))
Console.WriteLine(Array(1))
Console.WriteLine(Array(2))
Console.WriteLine(Array(3))
Console.WriteLine(Array(4))
Console.ReadLine()
End Sub
End Module
How it works is that a list of all possible values is built and as each possible value is randomly selected it is removed from the list of possible values. The Random number that is generated is used as the index into the list of PossibleValues. This technique could be used for any list of PossibleValues (say Months of the year, Days of the Week, Lottery Numbers, etc.) where you don't want to get the same value twice.
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event
|
|
|
|
|
Yes! There was one problem in your code. When I was debugging through your code, I had to change one line:
PossibleValues.RemoveAt(Counter)
This removes the Counter from the arraylist which in fact it should remove the number that was chosen for the new array from the arraylist. I did this by:
PossibleValues.RemoveAt(Index)
This solves the problem.
It is definetly good enough for me but I was trying to do the impossible. This was my vision as to what should happen.
You have 5 numbers (1,2,3,4,5)
Randomly select a number from those five
Lets say 3 - now the numbers left are (1,2,4,5)
Randomly select a number from those four
Lets say 4 - now the numbers left are (1,2,5)
Randomly select a number from those three
Lets say 2 - now the numbers left are (1,5)
Your array is (3,4,2)
Your code above does this but the random number selected is an index and not the true number. In your case, if the number chosen is a 4 then index = 4 and the number would be 5.
Now the array above has changed to (3,4,5)
I think this is impossible to mimick a true say lottery drawing.
Thanks for all of your help.;)
|
|
|
|
|
You could probably use the arraylist to check whether the same number has already been used.
Dim arr as New ArrayList
Dim Counter As Integer
Dim iCur as Integer
For Counter = 0 To 4
icur = CInt(Int((49 * Rnd()) + 1))
while arr.contains(icur)
icur = CInt(Int((49 * Rnd()) + 1))
end while
arr.add(icur)
Next
arr.sort()
lbl1.Text = arr(0)
lbl2.Text = arr(1)
lbl3.Text = arr(2)
lbl4.Text = arr(3)
lbl5.Text = arr(4)
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
It's a weird Life
|
|
|
|
|
Yes, this takes out the boolean that was used in this forum above.
Read the rest that is posted under this forum to see if you have the impossible answer.
Thanks
|
|
|
|
|
Oh, there was one line that you have forgotten to make this work. After:
arr.add(icur)
I had to add:
Array(Counter) = iCur
to add the number to the origional array.;)
|
|
|
|
|
Hi to all,
How can I paint the background of the MDIParent from by myself. Default backgroundImage property draws image multiple if it is smallest that the size of the form. And I need to paint the small image at the center of the form.
Regards,
Alex
|
|
|
|
|
What is the problem in using Paint event of the form?
|
|
|
|
|
The problem is: when I try to paint some image on the form there are no results! If I change isMDIContainer property to false, then all works fine. But if isMDIContainer=true then I can't see any results of OnPaint or OnPaintBackground functions call.
Regards,
Alex
|
|
|
|
|
|
im trying to make a slideshow kind of app in vb6 thats similar to MS powerpoint.
my idea is to use the MDI wizard and make each new child form as a slide.
my prob is , how do i access these children when i click on , say, a button called , run slideshow.
there must be some array of forms like MDI list where all the forms and their info must be stored right?
if i get that , then all i have to do is run a for loop and use form.show() !
any clues??
|
|
|
|