|
VB6 been dead for a long time. You better off using something like VB.Net instead.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hello
I have a small problem with combobox.
So the form has a panel with optionbuttons and dependin on the click of user,the combobox will display various items.
the problem is that how often i click the optionbutton,in the combobox the items are being replaced.alfer a few clicks the combobox is full with duclicated names.
how can i avoid this?
i use this code for optionbutton
Private Sub Option1_Click()
Label7.Caption = "Përdoruesi"
Call DB
ar.Open "Select *From tblPerdoruesit", strConek, adOpenStatic, adLockOptimistic
If ar.RecordCount = 0 Then
Exit Sub
Else
ar.MoveFirst
Do While Not ar.EOF
cboSubjekti.AddItem ar!EmriUser
ar.MoveNext
Loop
ar.Close
End If
End Sub
|
|
|
|
|
Where do you 'clear the combobox
combobox.items.clear???
Jan
|
|
|
|
|
Thank you for the help.
i used this code : cboSubjekti.Clear
|
|
|
|
|
hi,
i can change the web.config at run-time because its just like a text file.
is my approach is good thing to change at run-time?
the goal is to change database when the user clicks
a radiobutton, let say, rdoDB1 and rdoDB2.
the problem is grid are not reflecting to the new database but when i close the page then start again,
grid shows data with new database which set in web.config.
thanks in advance for your time.
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
sorry, i figure out already, i just create two connection string.
thanks
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
I use VS2008 where I have a program where I have about 20 tabpages with datagridviews and textboxes.
But when it comes to printing my form my programming skills is not good enough.
Here is how one of my forms looks like:
[IMG]http://i85.photobucket.com/albums/k72/johmolan/VB_NET/form1.png[/IMG]
I want to print out the data I have in my datagridviews with the columnheads, together with the data in my textboxes
and the labels explaining what the values are.
I have come to the conclution that there is no easy way to do this, but I still have my hopes up that there is a way to do this.
have anyone of you done something like this before and can give me a little hint on how to go on?
I had some thought on maybe to use somethong like the tabcontrol or something but as I said my skills aint that good yet but maybe some of you can lead me in the right direction.
|
|
|
|
|
I am afraid, you will have to get down and dirty with the PrintDocument Class[^] [MSDN] on this one. Your best bet is to design your output on paper first, and then use the PrintDocument class to recreate this with the printer.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Hello everyone,
Please look the code below. I use this on a formclosing event.
when i do a trace on the If Me.FireArmsTB_DataSet.HasChanges, it goes directly to the END IF to whatever dlgResult is.
what seems to be wrong here.
Using vb.net
Dim dlgResult As Integer
If Me.FireArmsTB_DataSet.HasChanges Then
dlgResult = MessageBox.Show(Me.Usernamelabel.Text & " " & " " & "êtes vous sûr de sortir sans avoir sauveguarder?", "Fermez!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes
If dlgResult = 6 Then
Me.FireArmsTBTableAdapter.Update(Me.FireArmsTB_DataSet.FireArmsTB)
ElseIf dlgResult = 7 Then
e.Cancel = False
Else
e.Cancel = True
End If
End If
Thanks in advance
|
|
|
|
|
waner michaud wrote: dlgResult = MessageBox.Show(Me.Usernamelabel.Text & " " & " " & "êtes vous sûr de sortir sans avoir sauveguarder?", "Fermez!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes
That results in dlgResult being a Boolean, being True or False . That don't make sense with the If statement that follows.
Is your Option Explicit OFF?
Bastard Programmer from Hell
|
|
|
|
|
I think you have to insert e.Cancel = True
If dlgResult = 6 Then
Me.FireArmsTBTableAdapter.Update(Me.FireArmsTB_DataSet.FireArmsTB)
e.Cancel = True
ElseIf dlgResult = 7 Then
e.Cancel = False
Else
e.Cancel = True
End If
Greetings from Germany
Horst
|
|
|
|
|
i have a form and bindingsource to a entity.i need to sort records using a field.But the sort property has no effect.
The code is :
------------------------------------------------------------
lstBindingSource.DataSource=context.lst
lstbindingsource.Sort="name ASC"
--------------------------------------------------------------
But , the records are not sorted by "name" column.
i try also :
----------------------------------------------------------------------
lstBindingSource.DataSource=from t1 in context.lst order by t1.name ascending
select t1
-----------------------------------------------------------------------
.... and this resolve my problem , but when i add a new record or modify the field "name" of an existing record , after that the records are not in order by "name".
What can i do to resolve this problem ?
Thank you.
|
|
|
|
|
alejx wrote: .... and this resolve my problem , but when i add a new record or modify the field "name" of an existing record , after that the records are not in order by "name".
Adding an item usually puts the item last in the list; even Explorer put new folders/files at the bottom of the list as opposed to re-sorting the entire list (until Win7). The list is sorted so you can find something quickly; re-sorting the list so you can find the item you just added doesn't make much sense, even though some users want to see it "sorted" "before" it's "saved".
I haven't worked with the EF, but I'd start here if I was facing the same.
Bastard Programmer from Hell
|
|
|
|
|
I want to read a sentence from a textbox characterwise and as soon as the space character comes the prevoiusly occured characters are to put in a label. I am having problems in array data types.
Here is the code.
Private Sub file_open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles file_open.Click
Dim count As Integer = 0
Dim objreader As New System.IO.StreamReader(file_name.Text)
TextBox1.Text = TextBox1.Text & objreader.ReadLine & vbCrLf
Dim myArray1() As Char = TextBox1.Text.ToCharArray()
Dim myArray2 As List(Of Char) = New List(Of Char)
For Each c As Char In myArray1
If c <> " " Then
myArray2.Add(c)
Else
id.Text = myArray2() ' here is the issue
Exit For
End If
Next
End Sub
|
|
|
|
|
of course that won't work, id.Text is a string, and at the moment myArray2 is a list of characters. In general, you can't assign two different types to one another.
Why did you start using a list? a list is not an array (although there is an array deep inside a list).
Please don't use confusing variable names, myArray2 is NOT an array at the moment.
Anyway, a string isn't an array of characters either, even when you can get at the string's characters one by one, as if it were an array of chars. However there is a string constructor that takes an array of chars.
I suggest you step back a bit, and consider choosing, buying and studying a book on VB.NET programming. That will teach you much more in a shorter period of time, and keep you from wasting your time in random experiments while the fundamentals seem missing.
As for your current quest, I think something along these lines
Dim text as string=TextBox1.Text + " "
id.Text=text.SubString(0, text.IndexOf(' ')) is all it takes.
|
|
|
|
|
Further to my answer to your previous question below, this example adds the label for the output;
Dim out As List(Of Char) = New List(Of Char)
If Not IsNothing(TextBox1.Text) Then
For Each item As Char In TextBox1.Text.ToCharArray
If item <> Chr(32) Then
out.Add(item)
Debug.WriteLine(item.ToString)
Else
Debug.WriteLine("Space found......stopping.")
Exit For
End If
Next
End If
If out.Count > 0 Then
Debug.WriteLine("Out Array Contains: " + out.Count.ToString + " items.")
Dim outString As New System.Text.StringBuilder
For Each item As Char In out
outString.Append(item.ToString)
Next
Label1.Text = outString.ToString
Else
Debug.WriteLine("No items in output array")
End If
|
|
|
|
|
Are you serious? Every character that would end up in the result would have been copied six times:
For Each item As Char In TextBox1.Text.ToCharArray
out.Add(item)
outString.Append(item.ToString)
Label1.Text = outString.ToString
BTW: If Not IsNothing(TextBox1.Text) Then is superfluous, TextBox.Text never returns null, when empty (or not explicitly initialized) it returns an empty string, as in ""
|
|
|
|
|
It works, I never said it was efficient! It would have been better just to shift the char straight to the target than through another builder.
When I ran the test this morning, without the line char copy failed when empty. I could have just as easily checked the length (which would have been better).
Anyway, the post is more to get the OP thinking, not necessarily give him the answer on a plate.
|
|
|
|
|
Hmm. I think your If out.Count > 0 Then is superfluous too. When the TextBox looses all its content at once (CTRL/A CTRL/X), the label needs to get cleared. Maybe you needed a coffee shot first...
I still prefer my two-line approach, no list, no SB, no loops.
|
|
|
|
|
|
Write an article on your work, that covers the design, concepts, and coding of your library and you can post that. Just posting a link here isn't going to be well received.
|
|
|
|
|
I have written a code to read a text box character by character and copy the characters into another array. As soon as the space character occurs the process should stop. the Program is giving argument null exception at runtime. Any solutions.
Here is the code.
Private Sub file_open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles file_open.Click
Dim objreader As New System.IO.StreamReader(file_name.Text)
TextBox1.Text = objreader.ReadLine
TextBox1.Text = TextBox1.Text & objreader.ReadLine & vbCrLf
Dim myArray() As Char
Dim myArray2() As Char
myArray = Me.TextBox1.Text.ToCharArray
For i As Integer = 1 To 70
If myArray(i) <> " " Then
Else
Array.Copy(myArray, myArray2, i)
End If
Next
End Sub
|
|
|
|
|
ArgumentNullException means one of the arguments is null ("Nothing" in your lingo).
Dim myArray2() As Char is not allocating any memory, it only tells the compiler myArray2 is going to refer to some char array, however you (or something you call) needs to pay for the memory (as Me.TextBox1.Text.ToCharArray did for the other array reference). Try the New keyword.
|
|
|
|
|
See the code below, this example using a textbox and a button for the example. The code below is in the button click event;
Dim out As List(Of Char) = New List(Of Char)
If Not IsNothing(TextBox1.Text) Then
For Each item As Char In TextBox1.Text.ToCharArray
If item <> Chr(32) Then
out.Add(item)
Debug.WriteLine(item.ToString)
Else
Debug.WriteLine("Space found......stopping.")
Exit For
End If
Next
End If
If out.Count > 0 Then
Debug.WriteLine("Out Array Contains: " + out.Count.ToString + " items.")
Dim outString As New System.Text.StringBuilder
outString.Append("Out contains: ")
For Each item As Char In out
outString.Append(item.ToString)
Next
Debug.WriteLine(outString.ToString)
Else
Debug.WriteLine("No items in output array")
End If
|
|
|
|
|
Private Sub factuurZoeken_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
m_SelectedStyle = New DataGridViewCellStyle()
m_SelectedStyle.BackColor = Color.LightBlue
m_SelectedStyle.BackColor = SystemColors.Highlight
DataGridView1.ReadOnly = True
Dim SQLString As String = "SELECT id, bedrijfsnaam, startdatum, vervaldatum, omschrijving, netto, bruto, opmerkingen FROM Facturen"
Dim DataSet As New DataSet()
Dim OleDbDataAdapter As System.Data.OleDb.OleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter(SQLString, oleConn)
oleConn.Open()
OleDbDataAdapter.Fill(DataSet, "Facturen")
DataGridView1.DataSource = DataSet.Tables("Facturen")
'hier kleuren:
DataGridView1.AutoResizeColumns()
checkfactuurvervallen()
oleConn.Close()
Catch ex As Exception
MessageBox.Show("Fout in Database : " & ex.Message)
oleConn.Close()
End Try
Then my sub factuurvervallen:
Private Sub checkfactuurvervallen()
'kleur records indien vrij of niet(haal datum vandaag op)
Try
Dim vandaag As String = Today
Dim i As Integer = 0
For Each row As DataGridViewRow In DataGridView1.Rows
If DataGridView1.Item(2, i).Value() > vandaag Then
DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.IndianRed
ElseIf DataGridView1.Item(2, i).Value() < vandaag Then
DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen
End If
i = i + 1
Next
Catch ex As Exception
MessageBox.Show("Fout in kleuren aangeven : " & ex.Message)
End Try
'tot hier kleuren
End Sub
If i pass the sub factuurvervallen() on a button it colors the rows but in my load after loading the rows it doesn't what am i overseeing??
thx in advance
|
|
|
|