|
Hi,
I must split a string after the numbers of his letters(the size of the string).
i want to do something like this:
dim str as string<br />
<br />
If Len(str) > 4000 Then<br />
str = str.Split(. ..)
help please
regards.
|
|
|
|
|
use the SubString method instead.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hello dear,
u can use this
str = Microsoft.VisualBasic.Mid(str, 4000)
or use
str = str.Substring(4000)
love
shally
sdf
|
|
|
|
|
|
shally_79 wrote: str = Microsoft.VisualBasic.Mid(str, 4000)
or use
str = str.Substring(4000)
Note that these give different results, as indices are one based in Mid and zero based in Substring .
---
single minded; short sighted; long gone;
|
|
|
|
|
First time here, thanks in advance for any help. I am currently finishing up a project that does not use Buttons and I have been able to move around through 50 user input boxes via the TAB key. I have used _Validating so when I TAB out of the block of code, the code is activated automatically.
TextBox1_Validating..............Checkbox1_Validating............, its all good and it all works. I only need the Checkboxes under certain scenarios and I cannot program and infinite number of scenarios, so, to make my project completely Button and mouse free, I would like to move from a textbox to a checkbox the sits right next to it when needed by pushing the Enter Key.
I have done my homework and have not seen anything of the sort, I do not need the Enter key anywhere else in my code nor does it work even if I accidently bump it.
Duane in Japan
Sorry, I have VB Studio '05.
|
|
|
|
|
Add the following line to your form load for each control that it is relevant for.
AddHandler uxControlWhereEnteredKeyPressed.KeyPress, AddressOf Me.NameOfEventToHandleThis Here's the event.
Private Sub NameOfEventToHandleThis(ByVal sender As Object, ByVal e As KeyPressEventArgs)
If e.KeyChar = Chr(13) Then
SelectNextControl(Me.ActiveControl, True, False, True, True)
e.Handled = True
End If
End Sub The False will stop on Non-tab stop items so just make sure your tab order is in the correct order but set the CheckBoxes to TabStop = False.
If you want to speed up adding the handler use the following snippet of code.
For Each ControlOnForm In Me.Controls
If TypeOf ControlOnForm Is TextBox Then
DirectCast(ControlOnForm, TextBox).KeyPress, AddressOf Me.NameOfEventToHandleThis
End If
Next I hope this helps.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Thanks for your assistance, sorry, I am still a bit new to naming conventions, I have been sticking to the default names so I am not sure what to insert into your code. This includes the Form Load line of code also please. I have set the TAB index up to what I believe is by your instructions. Here is a piece of what I am working with. Where do I insert your code and how do I name the events.
Private Sub TextBox5_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox5.Validating
Dim Box2 As Double = 0
Dim Box5 As Double = 0
If TextBox5.Text.Length = 0 Then
'http://msdn2.microsoft.com/en-us/library/139z2azd.aspx, MsgBox
MsgBox("A 'B1' value is required.", MsgBoxStyle.Exclamation)
e.Cancel = True
ElseIf Not IsNumeric(TextBox5.Text) Then
MsgBox("This 'B1' value is not numeric.", MsgBoxStyle.Exclamation)
e.Cancel = True
'http://msdn2.microsoft.com/en-us/library/system.windows.forms.checkbox.checked(VS.80).aspx, CheckBox
ElseIf CheckBox2.Checked Then
e.Cancel = False
Else
Box2 = CDbl(TextBox2.Text)
Box5 = CDbl(TextBox5.Text)
TextBox3.Text = CStr(Box5 + 1)
TextBox4.Text = CStr(Box2 - Box5)
End If
If Box5 <= 0 Then
MsgBox("Your 'B1' value must be greater than zero.", MsgBoxStyle.Exclamation)
ElseIf e.Cancel = True Then
End If
TextBox35.Clear()
TextBox36.Clear()
TextBox37.Clear()
TextBox38.Clear()
TextBox39.Clear()
End Sub
Private Sub CheckBox2_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles CheckBox2.Validating
TextBox35.Text = TextBox5.Text
TextBox36.Focus()
End Sub
If needed right now, I would like to hit the enter key and go from textbox5 to checkbox2.
Duane in Japan
|
|
|
|
|
If you double click on the form itself that is the form load event. You would put the handler piece in that method.
The other part would be it's own function and would happen when you hit enter in the textboxes that you assign a handler to. The validating would still occur and if it didnt validate correctly you would just call e.Cancel = True in the validating event.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
This is just one of ten exact calculation events, with the code that you gave, with limited infor from me, it worked but some code later in the calculator was not working properly.
The Enter key did something to the CheckBox and its name (CheckBox + Label) but it did not physically check the box, since my entire project is about Validating and the Checkbox was not actually Checked then code later did not run as intended.
Played with your code unnecessarily and played with some of my own guessing until I just had to add in CheckBox2.Checked = True. within your code so more of my code could run later.
Thanks again to all for this help, sorry for taking so long to get back, this forum moves fast.
I put the correct line of code in the Form.Load event up top too.
Private Sub TextBox5_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox5.Validating
Dim Box2 As Double = 0
Dim Box5 As Double = 0
TextBox5.SelectAll()
If TextBox5.Text.Length = 0 Then
'http://msdn2.microsoft.com/en-us/library/139z2azd.aspx, MsgBox
MsgBox("A 'B1' value is required.", MsgBoxStyle.Exclamation)
e.Cancel = True
ElseIf Not IsNumeric(TextBox5.Text) Then
MsgBox("This 'B1' value is not numeric.", MsgBoxStyle.Exclamation)
e.Cancel = True
'http://msdn2.microsoft.com/en-us/library/system.windows.forms.checkbox.checked(VS.80).aspx, CheckBox
ElseIf CheckBox2.Checked Then
e.Cancel = False
Else
'http://msdn2.microsoft.com/en-us/library/ewf8xx62(VS.80).aspx, Convertion
Box2 = CDbl(TextBox2.Text)
Box5 = CDbl(TextBox5.Text)
TextBox3.Text = CStr(Box5 + 1)
TextBox4.Text = CStr(Box2 - Box5)
End If
If Box5 <= 0 Then
MsgBox("Your 'B1' value must be greater than zero.", MsgBoxStyle.Exclamation)
ElseIf e.Cancel = True Then
End If
TextBox35.Clear()
TextBox36.Clear()
TextBox37.Clear()
TextBox38.Clear()
TextBox39.Clear()
End Sub
Private Sub TextBox5_Validating(ByVal sender As Object, ByVal e As KeyPressEventArgs)
If e.KeyChar = Chr(13) Then
SelectNextControl(Me.ActiveControl, True, False, True, True)
CheckBox2.Checked = True
e.Handled = True
End If
End Sub
Private Sub CheckBox2_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles CheckBox2.Validating
TextBox35.Text = TextBox5.Text
TextBox36.Text = 0
TextBox37.Focus()
End Sub
|
|
|
|
|
I manually re-ordered the DataGridView columns many times until I thought, Ahhh I can do this in code, so I did the following (note this grid contains many columns but I removed them for simplicity).
uxInformationGrid.Columns.Clear()
Me.uxInformationGrid.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.IDColumn, Me.NameColumn}) The problem with this is that it doesnt do anything. Is there a piece missing from here?
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
hello,Please try by changing DataGridViewColumn() to DataGridViewTextBoxColumn
shally
|
|
|
|
|
I need to get a dataview containing the sums, counts and averages of columns in a datatable that have the
same value in another column. For instamce the SUM returned dataview from this table:
A B
1 5
2 10
1 5
2 10
should return
A B
1 10
2 20
What is the computationally fastest way to do this?
tia!
|
|
|
|
|
Make a nested query. Example:
select Cnt, sum(Value)
from (
select count(*) as Cnt, Value
from SomeTable
group by Value
) as x
group by Cnt
---
single minded; short sighted; long gone;
|
|
|
|
|
OK, I see that an SQL query is good.
But I have a local datatable -- it doesn't have or need an SQL connection or dataadapter.
Should I make one to do this selection? (seems like a lot of overhead?)
Or is there a better alternative - perhaps a loop is faster?
Thanks
|
|
|
|
|
cstrader232 wrote: But I have a local datatable -- it doesn't have or need an SQL connection or dataadapter.
Should I make one to do this selection? (seems like a lot of overhead?)
Using a DataTable when the data doesn't come from a database seem like a lot of overhead in the first place...
cstrader232 wrote: Or is there a better alternative - perhaps a loop is faster?
Yes. There are dictionaries and sorted lists that you can use to easily group and sort the data.
---
single minded; short sighted; long gone;
|
|
|
|
|
Well I thought that sorted lists were not very efficient. I don't know what a dictionary refers to
in this context. Can you direct me?
ty
|
|
|
|
|
cstrader232 wrote: I don't know what a dictionary refers to in this context. Can you direct me?
MSDN Library: Dictionary[^]
---
single minded; short sighted; long gone;
|
|
|
|
|
greetings to all... i really appreciate your help it gives me new ideas and gives me more closer to what i wanted to do...
now again i need your help on how to enable to allow sorting on a gridview in which the column header not came from the controls design, but instead from run time...
start a new beginning in every ending; thats what life for......
|
|
|
|
|
try this one
datagridview1.sort(columnindex)
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
this helps although its a little bit closer of what i wanted but i appreciate this code sir... its a great help..
but i need this one:
whenever you click the header of the gridview it will sort to descending and ascending manner....
this is easy if i use a bind gridview, but if i use run time or unbound data to the gridview then its the time i have difficulties in sorting columns by its column header...
Thank you sir...
start a new beginning in every ending; thats what life for......
|
|
|
|
|
use following code
Private Sub dgv1_ColumnHeaderMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgv1.ColumnHeaderMouseClick
dgv1.Sort(dgv1.Columns(e.ColumnIndex), ComponentModel.ListSortDirection.Ascending)
End Sub
where dgv1 is datagridview object
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
Please don't cross post.
Please try to write a subject line that is relevant.
---
single minded; short sighted; long gone;
|
|
|
|
|
did i not ask for an apology at the last part of my post?
that i mistakenly post my question on this forum VB.NET
that is supposedly for ASP.NET
before you judge, pls read or understand what is written on the post...
Thank You...
start a new beginning in every ending; thats what life for......
|
|
|
|
|
If you ever cross post you have the ability to delete your post before there are replies.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|