|
I'm writing a program that converts a number in a textbox from one metric unit to another. I need to write an if statement that will validate that what is in the textbox is a numer and if it isn't returns a message box. any suggestions with code samples would be appreciated.
BINARY
|
|
|
|
|
Try the Parse method in the Int32 class. Something like
Dim number as Int32
Try
number = Int32.Parse(textBox.Text)
Catch
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Why not do it the smart way and use one of the many controls on this site that give you a text box which only accepts numbers ?
Otherwise, I'd use a regular expression to pull a number out before I did a try/catch, that's just ugly.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I ended up using IsNumeric to validate the textbox. Thanx all.
BINARY
|
|
|
|
|
try this
IsNumeric("$1") returns true
this is wrong.
|
|
|
|
|
I famliar with list boxes and loading them either in code, through the properies menu, and/or loading items from a db. What I would like to know is...Is there a way to make some items selectable and others not? For example, I would like to load a single list box with informational items that are sent based on a time period. I would like to use the time period as a separator of the items.
1st Trimester
Ed Material 1
Ed Material 2
2nd Trimester
Another Ed Material
3rd Timester
Yet another or more
I would like to select the items, but not the time period. While there are other ways for me to identify or even break this out, I would like to use a single list box.
Thanks for the help.
Mtognetti
|
|
|
|
|
There is no built in functionality for this. But you can handle the SelectedIndexChanged event to check whether some of those items was selected if if so you jsut have to deselect it by yourself.
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim notSelectableIndices As Integer() = New Integer() {2, 5, 8}
Dim index As Integer
For Each index In notSelectableIndices
If (ListBox1.GetSelected(index)) Then
ListBox1.SetSelected(index, False)
End If
Next
End Sub
|
|
|
|
|
Thanks! That is exactly what I was looking for. The only addition that I made was to set the notSelectedIndices array to be somewhat dynamic because I have three elements that I do not want selected and the number of elements under each one could change with time...
Dim index As Integer
Dim idexArray(2) As Integer
Dim strEval As String
Dim i As Integer = 0
Dim j As Integer = 0
'Evaluate which items in the list box should not be
'allowed to be selected
'If the list was larger this would be set globally once and used
For i = 0 To lbEducationalMaterials.Items.Count - 1
strEval = Microsoft.VisualBasic.Left(lbEducationalMaterials.Items.Item(i), 2)
If strEval = "--" Then
idexArray(j) = lbEducationalMaterials.Items.IndexOf(lbEducationalMaterials.Items.Item(i))
j += 1
End If
Next
'set the total bound of the array
i = idexArray.GetUpperBound(0)
'identify and unselect items
For Each index In idexArray
If (lbEducationalMaterials.GetSelected(index)) Then
lbEducationalMaterials.SetSelected(index, False)
End If
Next
Again, thanks for the help.
Mtognetti
|
|
|
|
|
I'd like to write a form in Access that could do one of two things:
1. Control either my Mozilla or IE webbrowser to refresh the page, search the page for certain words, then notify me.
or
2. Control an activex webbrowser within an Access form to refresh the page, search the page for certain words, then notify me.
I tried to put an activex webbrowser within a Access form then use the:
[control].navigate command, however I get an error message stating "error: Expected: string constant" I think I'm using the wrong references, but I have no idea.
Thanks.
|
|
|
|
|
I have a problem with data in a text file. my data is a row in a data grid, but when i write my data to the file it writes it like this: 101405johnsmith050605. when it writes the data row like this, how do i get certain things to certain places? like 10 would be the record number and john smith would be the payee and 050605 would be the date. since it is not writen like this I cannot get john smith to textbox2 on form2 and i cant specify that i want 050605 to textbox3 form 2. how do i write the datarow so i can have certain pieces of it go to certain textboxes?
Makniteasy
|
|
|
|
|
Hello,
What technique have you adopted to write the data into the file? I think you should append space " " at the end of each data element while writing to the file.
HTH.
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
I am looking for advice on a client server architecture. I will have several windows clients 200-1000 that will on 5 min. interval send a small amount of data aswell as query for a simple response.
I have looked at WEB services, .NET remoting and sockets, but not able to find concrete info on performance for such a setup. Any suggestions or leads would be appreciated. My language is c#/VB.NET. My biggest consern is perfromance as th clients are gathering info themselves as a possible service then preiodically sending updates to the server for collecting data centrally.
Thanks in advance for your response
|
|
|
|
|
Do you know why i can't write my text in a textobject in separate line in a Crystal Report Document???
I tryed very hard but ....
If someone know the solution i'll thank you...
|
|
|
|
|
I am working on a VB6 application which also uses Crystal Reports. However whenever I run my form I get this error message "Invalid formula name". I was wondering if anyone knew how to correct this problem or reset the formula name. Any useful suggestions would be great.
|
|
|
|
|
I have the following code but when it gets to the "Cmd.ExecuteNonQuery()" it just stops and throws an error. anyone any ideas why this is not working?
Cmd = New SqlCommand("sproc_DomainName", Conn)
Cmd.CommandType = CommandType.StoredProcedure
Param = Cmd.Parameters.Add("@domainName", SqlDbType.Char, 64)
Param.Direction = ParameterDirection.Input
Param.Value = strUser
Param = Cmd.Parameters.Add("@staffID", SqlDbType.Int, 4)
Param.Direction = ParameterDirection.Output
Param = Cmd.Parameters.Add("@roleID", SqlDbType.Int, 4)
Param.Direction = ParameterDirection.Output
Param = Cmd.Parameters.Add("@firstName", SqlDbType.Char, 20)
Param.Direction = ParameterDirection.Output
Param = Cmd.Parameters.Add("@surname", SqlDbType.Char, 20)
Param.Direction = ParameterDirection.Output
Conn.Open()
Cmd.ExecuteNonQuery()
Conn.Close()
|
|
|
|
|
|
I have an MDI child form. When the user uses the arrow keys to go between main menu items they can get to both the child forms system menu and the parent forms system menu. How do I delete/remove the child forms system menu? I've tried the ControlBox property but that doesn't work (VB.NET bug?). I've also tried deleting all the items in the system menu using API calls but that still leaves the little icon. Thanks so much for any help. I've looked everywhere but can't seem to find anything.
|
|
|
|
|
Can someone please explain the difference between LDAP and MAPI? When should one be used instead of the other?
Thanks,
Sam
|
|
|
|
|
LDAP -> Lightweight Directory Access Protocol. Used to access directories that contains many kinds of information about networks, users, computers, services, ...
MAPI -> Messaging Application Programming Interface. Used by email applications to send and receive mail through certain messaging systems.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I need to have the records from my Ms Sql table between two dates.
I have a Vb.Net form and two DateTimePicker on it to get the first and second date.
What must sql tables "DateKeeper" coloumn type be?(smalldatetime for dd.mm.yyyy?)
And in which type i have to send my dates that i receive from DateTimePickers?
If possible plz write the Select sentence of this code.("select * from MyTable Where DateKeeper>=firstDate And DateKeeper
|
|
|
|
|
hakanaktan wrote:
What must sql tables "DateKeeper" coloumn type be?(smalldatetime for dd.mm.yyyy?)
That depends on how fine grained you want your dates and what range of dates you want. You know that the most important tool of a good developer (assuming you aspire to be more than a coder and become a developer) is to be able to find stuff in the documentation. Google is a great way to find stuff. Try this in Google:
site:msdn.microsoft.com smalldatetime And the first link is datetime and smalldatetime[^] which tells you exactly the accuracy and range of the two chronological types in SQL Server.
hakanaktan wrote:
And in which type i have to send my dates that i receive from DateTimePickers?
The DateTimePicker will give the date in a DateTime object, you don't need to convert it if you create your SqlCommand properly (by using parameterise queries)
hakanaktan wrote:
If possible plz write the Select sentence of this code.("select * from MyTable Where DateKeeper>=firstDate And
SELECT * ??? You should be listing each of the columns you want. If your data model changes then you could break your .NET application to easily without knowing immediately. If you don't know immediately then it becomes harder to track where the bug came from.
The SQL you need in your SqlCommand.CommandText is something like this:
SELECT MyColumn1, MyColumn2
FROM MyTable
WHERE DateKeeper>=@firstDate
AND DateKeeper<=@lastDate
Your SqlCommand object will take two Parameters
MyCommand.Parameters.Add("@firstDate", firstDateTime);
MyCommand.Parameters.Add("@lastDate", lastDateTime);
hakanaktan wrote:
-MCP& MCAD &junior coder--
I noticed you added MCP and MCAD to your signature recently. Congratulations on passing these exams.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Thank you very much for your detailed answer to my questions..
-MCP& MCAD &junior coder--
|
|
|
|
|
Can anyone please tell me know how to connect to a remote computer, not shares using vb.net. I want to connect to remote computer and get available shares on the computer and list them.
I just want to connect to \\server not \\server\share.
After connecting i want to retrieve the shares.
Thanks in advance
Aniruddha
|
|
|
|
|
Hi,
Can any one help me by telling how to call a windows application (standard exe) from vb.net
Thank you
Mahesh
|
|
|
|
|