|
How do I remove a hyphen from a text?
I'm retrieving the value from a textbox. The value, for example is 567-343, how do I get rid of the hyphen? The trim("-") function doesn't work on this value.
Thanks!
|
|
|
|
|
Trim only removs the specific char from start and end of the string.In order to remove the char inbetween the string you can use split method or regular expression.I think in your case split method should be good enough.you can refer this code segment
Dim FinalString as String
Dim ActualString as String ="567-343"
Dim splitString() as String=ActualString.split
'this returns an array of String
Dim i as integer
For i=0 to SplitString.length-1
if not(SplitString(i)="-") then
FinalString=FinalString & SplitArray(i)
end if
next
Hope this Helps
Mandar Patankar
Microsoft Certified professional
Today Was not that Good..But I got tommorow..
|
|
|
|
|
Dim yourString as String = "567-343"
yourString = Replace( yourString, "-", "" )
Have a wonderful evening
Doug Wright
Developer, TDCI
|
|
|
|
|
who know how to plot graph in vb.give me sourcecode or example to plot graph and sourcecode for serial port in vb
|
|
|
|
|
Hi all!
I´m newbie using Vbasic. I need to make a macro for Excel, which
shows a form asking for a numeric value in a Textbox.
I convert the Textbox content to long with CLng() function.
<br />
Dim longval As Long<br />
longval=CLng(TheTextBox.Text)<br />
But this function crashes if the content of the textbox is alphanumeric.
How can I check that the value entered is only numeric?
Is there any function like "IsDigit" or something?
or
Is there any Textbox property to force only numeric content?
Thanks a lot.
|
|
|
|
|
If IsNumeric( TheTextBox.Text ) Then
longval = CLng( TheTextBox.Text )
Else
longval = SOME_DEFAULT_VALUE
End If
- dougw48
dwright@tdci.com
|
|
|
|
|
Thanks for your help!!
|
|
|
|
|
How can we go about creating a sleek GUI like those of Apple iTune player, QuickTIme Player, Media Player, RealPlayer etc with custom buttons, background shade etc ?
I certainly hope thats possible in VB6.
|
|
|
|
|
mecracked wrote:
I certainly hope thats possible in VB6.
Possible, but not easy. You essentially have to create all the forms and custom controls from scratch, ownerdrawing nearly everything. Something VB6 doesn't lend itself to easily and you'll find less and less help for this project on the web.
It would be much easier to do in C++, C#, VB.NET, ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i'm a beginner user of vb.net.. i doing an application recently but i facing some of the problems. The problem is i don't know how to display the data from database and display it on the data grid so can anyone expert teach me how to do it?
|
|
|
|
|
see first thing you have to connect with the database and get the data from data u can get through dataAdapter.Then if u desugned dataset in ur app fill the dataset table with dataadapter then give the datasource for datagrid as dataset table
see the code as foows
Dataadapter.Fill(dataset.datatable)
Datagrid.DataSource=Dataset.datatable
U can directly also fill table
|
|
|
|
|
Hello everybody. I am having a problem with the picturebox control. I need to be able to print the containts of the picture box to a printer. I can't find the way to do it. I have a printPreview control which i can make to show the paper but i can't put the image in it and thus i can't make it to print.
I use e.Graphics.DrawImage(PictureBox1.Image, 0, 0) which puts the image in the paper, but not where i want it. I need the width of the image to fit to the width of the page between the margins, and the height of the image to be proposinal enlarged, or reduces so it follows the original aspect ratio of the picture. The origin of the picture to be in the corner of the top and left paper margin.
Arggg!! Any help! Pleeeeazeee!!
Trying to find the way
|
|
|
|
|
|
I created project using Remoting.
I created a Remoting Object have 2 function: one return a String and one return a Bitmap. The first function is Ok, but the second is not Ok. The Error occur that " Remoting cannot find field nativeImage on type System.Drawing.Image"
How can I do?
Can you help me! Thanks.
quangthien
|
|
|
|
|
Hi,
I am looking for a way to change a file's permission so that users does not have any access to the file. I would do this through code.
Any suggestions?
Thanks,
|
|
|
|
|
File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden)
You can set whatever attributes you like, but you can't cause users who go looking to be unable to access the file, unless your program is logged in as admin, and they are not.
BTW, that C# code above, you'll have to convert it ( change | to OR, etc )
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Thanks for the reply Christian. I came accros FileIOPermission in VS.NET help. Could this be use to accomplish what I want to do? I tried the following but it had no impact as far as I can tell.
Dim fileIOPerm1 As FileIOPermission
fileIOPerm1 = New FileIOPermission (FileIOPermissionAccess.NoAccess, "D:\test.txt")
fileIOPerm1.AllFiles = FileIOPermissionAccess.NoAccess
Thanks,
|
|
|
|
|
The MSDN on this is here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritypermissionsfileiopermissionclasstopic.asp[^]
Personally, I'm not sure how it could work globally - on what basis are you providing this permission ? Surely if you removed access to all files across all of Windows, the OS would crash and you'd never be able to log in again ?
Reading it, I think it allows you to specify what files the currently logged in user can access via operations of the File class, i.e. within your code only. That makes sense to me.
Making the files hidden is the best you're going to do IMO. If you deny them access, how is your code ( which runs under their security ) going to read or use it ? If the file is hidden and they find/mess with it, it's their problem. Hell, even if it wasn't hidden, it's their problem.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Thanks Christian. I appreciate your help on this.
Zenu
|
|
|
|
|
Even if you hid the file, they would still have access to it. The only thing that will take away all access rights would be using NTFS permissions. But, you have a huge problem! It is possible for your application to take away the rights to the file, but impossible for it to get them back. The application runs in the security context of the user who launched it. Once this person gives up all his/her access rights to a file, there is not enough rights left to get access to it back.
Like Christian said, it's up to the user to behave around these files. If not, he/she shoot themselves in the foot and that's not your problem.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi I was wondering if anyone out there could point me in the right direction. I am attempting to create custom controls that would be allow for the binding of data. Eg.the checked list box. This control does not allow a user to bind data from a dataset through the properties section of a control. I am looking to bind the checked list box and listview controls in VB.net. Thank you.
|
|
|
|
|
Hi... I am a new user of VB.net so I appreciate this forum.
I am trying to set the DataSource for a DataGrid control on my form using code. Very straight forward question with a very straight forward answer that works well:
Me.daDataAdapterName.Fill(Me.DsDataSourceName.StoredProcedureName_SEL)
However, the DataAdapter and the DataSource for the Datagrid may change based on values from an underlying SQL Table. I want to set the DataAdapter and the DataSource to be based on values from this Table.
This is a very straight forward question and I have properly identified the values that I want and declared them as variables. Now, I want to use the variables in the appropriate statement when declaring the DataAdapter and DataSource for the Datagrid. Being that my background is in VBA, I would have used the following syntax:
Dim V1 as String (Whatever the Name of the DataAdapter is)
Dim V2 as String (Whatever the Name of the DataSet is)
Me." & V1 & ".Fill(Me." & V2 & " .NameofStoredProcedure)
This syntax does not work. What is the appropriate syntax for VB.net?
I have tried variations...
Me.[" & V1 & "].Fill(Me.[" & V2 & "] .NameofStoredProcedure)
and
Me.[" + V1 + "].Fill(Me.[" + V2 + "] .NameofStoredProcedure)
Nothing seems to work.
Suggestions would be greatly appreciated.
Thanks in Advance
Pat
|
|
|
|
|
You're wasting your time. You can't do what your looking at doing. On top of that, there is no reason to do it either.
What is this code trying to accomplish? I mean over and above needlessly trying to change the name of a variable...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Dave...
The code is trying to accomplish the following:
I am a firm believer in ComboBoxes to enter data. Whether you agree with this approach or not, is not the issue. All of my Comboboxes are limit to list – for very good reason. Accordingly, there must be some provision so the user can enter new choices into the database:
Method:
Historically (in VBA in MS Access) my method is pure simplicity: 1 Form, 1 Combobox, 1 Subform (Datasheet view), 1 SQL Table
• The Subform and all of its cells are unbound
• The layouts for the Subform, (Datasource, Number of columns, widths, etc) are set from a single DataTable.
• If the user wants to enter a new “City”, he/she chooses City in main Combobox
• Based on the value of the Combobox, a single record in the Table is accessed.
• This record provides information on how to setup the Subform (the number and widths of the columns, datasource etc)
• All of the existing choices then appear in the subform and the user is then able to make the necessary edits/additions.
Using VB.net: 1 Form, 1 Combobox, 1 Datagrid, 1 SQL Table.
• The Datagrid has no Datasource
• The Based on the choice from the single ComboBox, a SQL Table is accessed.
• This record provides information on how to setup the Datagrid (DataAdapter, DataSource, Stored Procedure, the number and widths of the columns, etc)
• All of the existing choices then appear in the Datagrid and the user is then able to make the necessary edits/additions.
This may sound complicated, in fact, it would be as simple as defining two variables (V1 and V2):
• Where V1 is the name of the DataAdapter.
• Where V2 which is the name of the Dataset.
Declaring these variables along with their appropriate values is easy but it brings me back to my original question… What is the proper syntax?
Me.V2.StoredProcedure.Clear() (Normally would read… Me.NameOfDataSource.StoredProcedure.Clear)
And
Me.V1.Fill(Me.V2.StoredProcedure) (Nomally would read…
Me.NameofDataAdapter.Fill(Me.NameofDataSource.StoredProcedure))
I am not trying to needlessly change a Variable. However, if I can set the DataAdapter, DataSource, columns, etc, for over 25 choices from a single form and a single Datagrid, then I have...
• far fewer controls;
• fewer datagrids (1 vs 25);
• a single place to add/edit Master List choices;
• less code to write/edit/maintain (a single function that contains roughly 25 lines of code)
• BUT the real beauty of this is that if I want to add another ComboBox to my application, I simply add a single record in the SQL Table identifying the appropriate DataAdapter, DataSource, Number and Widths of Columns, etc. I then add or modify a single DataAdapter and I am ‘good to go’
This is why I am wondering about a simple little piece of code although, I guess I could have 25 datagrids layered on the form.
Thanks
Pat
|
|
|
|
|
Capilano wrote:
I am a firm believer in ComboBoxes to enter data. Whether you agree with this approach or not, is not the issue.
Excuse me, but when did I say using ComboBoxes was a bad idea?
Capilano wrote:
Historically (in VBA in MS Access) my method is pure simplicity: 1 Form, 1 Combobox, 1 Subform (Datasheet view), 1 SQL Table
• The Subform and all of its cells are unbound
• The layouts for the Subform, (Datasource, Number of columns, widths, etc) are set from a single DataTable.
• If the user wants to enter a new “City”, he/she chooses City in main Combobox
• Based on the value of the Combobox, a single record in the Table is accessed.
• This record provides information on how to setup the Subform (the number and widths of the columns, datasource etc)
• All of the existing choices then appear in the subform and the user is then able to make the necessary edits/additions.
Using VB.net: 1 Form, 1 Combobox, 1 Datagrid, 1 SQL Table.
• The Datagrid has no Datasource
• The Based on the choice from the single ComboBox, a SQL Table is accessed.
• This record provides information on how to setup the Datagrid (DataAdapter, DataSource, Stored Procedure, the number and widths of the columns, etc)
• All of the existing choices then appear in the Datagrid and the user is then able to make the necessary edits/additions.
This may sound complicated, in fact, it would be as simple as defining two variables (V1 and V2):
• Where V1 is the name of the DataAdapter.
• Where V2 which is the name of the Dataset.
Declaring these variables along with their appropriate values is easy but it brings me back to my original question… What is the proper syntax?
This is what we needed! But, there is no proper syntax. What you want to do is possible, just not how you want to do it. You have to rethink your logic to use collections of objects, like a collection of DataAdapters. It's impossible to use "variable variable names".
A hash table can hold on to all the DataAdapters you want, in a key/value, or in your case, key/object, pair. The key will be the name of the adapter, and the object will, of course, be the dataadapter.
Hashtable Class[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|