|
Hi,
remark: I will use - to indicate a space
1. in a string s the statement s=s.Replace("--","-") would replace every pair
of spaces by a single space; so 7 spaces would become 4 spaces.
2. if you redo step 1 the number of spaces would be further reduced; you could loop over 1.
until the length of s no longer changes.
3. you can apply the above to myRichTextBox.Rtf
With the above, you would have fewer than 10 lines of code to remove all multiple spaces.
BTW: if you want to leave double spaces as is, replace step 1 by s=s.Replace("---","--")
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hello,
I've got some questions about a combobox and a listbox:
- First: I want the value of the selected item in a combobox / listbox, how do I that. It is not with me.combobox.valuemember, but what is the correct code of it?
- Then: If the focus is on the combobox, I want the combobox is dropped down, so that I don't have to click on the combobox to drop down all the choises.
- Next: If I save all the values of the fields on a form, then I clean all the fields with: me.textbox.text = "", but how does I do that with a combobox / listbox?
|
|
|
|
|
hi xebe'
First: I want the value of the selected item in a combobox / listbox, how do I that. It is not with me.combobox.valuemember, but what is the correct code of it?
use following statement
dim str as string<br />
dim id as string<br />
str=combobox1.selectedItem<br />
id=combobox1.selectedValue
Next: If I save all the values of the fields on a form, then I clean all the fields with: me.textbox.text = "", but how does I do that with a combobox / listbox?
use for Each loop for clean all textbox,ComboBox,ListBox
Dim a As New System.Windows.Forms.Control<br />
For Each a In me.Controls<br />
If TypeOf a Is TextBox Then<br />
a.Text=""<br />
elseif TypeOf a Is ComboBox then<br />
a.selectedIndex=-1<br />
elseif TypeOf a Is ListBox then<br />
a.selectedIndex=-1<br />
<br />
End If<br />
Next
Hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Thank you very much, but I still don't know when the focus is on a combobox, how I must program that the combobox is already drop down and that I or a user should press the combobox button to be dropped down, hope someone can help me...
Also the combobox is still filled with the value I have entered in the field, so the code of
<br />
elseif TypeOf a Is ComboBox then<br />
a.selectedIndex=-1<br />
doesn't work.
Hope you can help me...
|
|
|
|
|
Also the combobox is still filled with the value I have entered in the field, so the code of
elseif TypeOf a Is ComboBox then
a.selectedIndex=-1
doesn't work.
use one more statement after statement(a.selectedIndex=-1)
a.text=""
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
user...
me.combobox.selectedvalue..... in getting the value...
and use
me.combobox.clear... to remove all data in it...
|
|
|
|
|
hi,
I mean you need to get combobox with select:
If u hv 'Select' item in combo with text 'Select' and its value '0' then
write :
Combobox1.selectedIndex=0
|
|
|
|
|
hi all...
we are using cmb1.findString("jj") method to find a text(display member) in the combobox .. like this i want to search a value member in a combobox... does any 1 have idea...
cheers..
|
|
|
|
|
YOu may need to iterate and compare through the Items collection right?
|
|
|
|
|
i cant run my program, there's an error:
Type 'BOOK_Locator.Dataset1' is not declared
in codes:
Friend WithEvents DataSet11 As BOOK_LOCATOR.DataSet1
i have connected my database in connection wizard properly but why there's an error in it? how can i fix?
|
|
|
|
|
Don't cross post.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi and good evening everybody i am fairly knew to vb.net and i have only just ventured into including xml files into my applications what i need help with is how would i be able to count how many lines there are between each parent node for example( what i will be using in my app )
<code><command>
<out>
<out>
<out>
<out>
</command></code>
but how would i be able to count how many <out>'s there are between the <command>'s and be able to use the line numbers else where in my application.
All help is great help no matter how small i just need a gentle push in the right direction.
Thanks
MrScruff
Trouser Jazz, Get A Move On Keep It Solid Steel
|
|
|
|
|
You would use XPath and the XmlDocument class to do this sort of stuff. In every instance, you cannot count lines, unless you regard it as a text file. You can count nodes on a level, that is, you can tell that code has one node under it, or command has four under it, or you can write a recursive function to count all the nodes.
The big question is, why do you want to know ?
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Hi, i'm having huge problems with my database connections. I let vb generate all the code for the data connections and for the table adapters and that was populating the dataset fine. The problem comes in when i move my application to another folder. The connection string is hard coded for the existing location. I changed the connection string data source property to
Data Source=..\..\Data\DigitalFusion.mdb in the app.config file(it was
Data Source=|DataDirectory|\DigitalFusion.mdb). Things were working fine, database was getting updated when i made a change but if i clicked the data tab on the menu and selected preview data it would give me an error stating that it could not locate the database. Nevertheless i continued on with coding and was attempting to create data relations between my tables so I could fill a datagrid using the relation as the data member and then all of a sudden 37 error messages popped up all to do with the dataset. The errors I believe have to do with the fact that the dataset is still trying to use the existing sonnection string instead of mine. can anyone help me with instructions on sorting this out by telling me where I need to change the connection string so it isn't a fixed location and so i can regenerate my datasets and preview their data. I'm desperate please help
|
|
|
|
|
erm, dont know if this helps, go to the menu Project > Ur project properties > Settings.
From there you can see all the connection strings that you have, you can easily change the datasource. i dont know if this beats changing the datasource manually in the config file but well just give it a try.
|
|
|
|
|
Mr Oizo wrote: The connection string is hard coded for the existing location
Bad Bad Programming. You should have used App.Config for that purpose.
Check out http://www.connectionstrings.com/[^]
|
|
|
|
|
Hi. What i meant is that for my connection I selected the Data Tab - add new data source menu button. I then selected the database from the list. But vb seems to automatically hard code the connection string to that fixed location. I then went to the app.config file and changed the connetion string properties data source to "../..Data/databasename.mdb". so that should of allowed me to acces the database regardless of the application folder location. The problem comes in now that my solution says the dataset doesn't exist and that the location of the database doesn't exist. Anyways i'll check that site you listed and hopefully I will find my answer there. thanks
Mr Oizo
|
|
|
|
|
i m inserting the code here, i want to add the administrator and general users and also to provide the facility to change his/ her password or name.
so plz help me...
________________________________________________________________
Public Class FrmLogin
Dim dsetsearch As New DataSet
Dim dsetusertype As New DataSet
Private Sub FrmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
dsetsearch.Clear()
If Me.txtuname.Text = "" And Me.txtupassword.Text = "" Then
MsgBox("User Name or Password not found", MsgBoxStyle.Information)
Exit Sub
End If
If Me.txtuname.Text <> "asif" And Me.txtuname.Text <> "imran" Then
MsgBox("Invalid User Name", MsgBoxStyle.Information)
Exit Sub
End If
gridfill("select * from Login where UserName = '" & Me.txtuname.Text & "'")
adp.SelectCommand.ExecuteNonQuery()
cn.Close()
adp.Fill(dsetsearch, "Login")
If Me.txtupassword.Text = CType(dsetsearch.Tables(0).Rows(0).Item(1), String) Then
Frmstartup.Show()
Me.Hide()
Else
MsgBox("Invalid User Name or Password ", MsgBoxStyle.Information)
End If
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
End
End Sub
Private Sub txtuname_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtuname.KeyPress
If Char.IsLetter(e.KeyChar) = False Then
If e.KeyChar = CChar(ChrW(Keys.Back)) Or e.KeyChar = CChar(ChrW(Keys.Space)) Then
e.Handled = False
Else
e.Handled = True
End If
End If
End Sub
End Class
asif rafiq
|
|
|
|
|
1 - don't ever pull the real password into your app
2 - it's best to never hard code a user/password, it means it cannot be changed
3 - use Char.IsControl to work out if a control character has been pressed
4 - what do you want to do ? Add users based on their role on the PC, so check if the user is an admin on the machine, and if so, they are in ? why ?
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
5 - SQL Vulnerability (?)
|
|
|
|
|
asifullahkhan wrote: gridfill("select * from Login where UserName = '" & Me.txtuname.Text & "'")
Very interesting query. Your database has good avenues or windows for easy cleanups. Wouldn't it be?
|
|
|
|
|
Hi all!
I want to figure out how I could place scrollbars onto a panel so that I could see things in the panel that are located outside the panel dimension.
The reason for doing this is because the panel is used as a canvas for the charts that I have drawn onto using the graphics object. Since the preset panel dimension could not be able to show everything. help needed!
thanks in advance!
jensen
|
|
|
|
|
Did you try placing it within a Scrollable DIV?
|
|
|
|
|
Where in his post did it say he was using ASP.NET??
|
|
|
|
|
Draw your stuff on one panel and place that panel inside another. Just set the AutoScroll property of the parent container panel to True.
|
|
|
|