|
If you want to convert a string to an int use Int32.Parse(mystring). If you want to validate input (requiring numeric values only, for instance) use regular expressions.
|
|
|
|
|
Just something like this will work:
If IsNumeric(Textbox1.Text) Then<br />
' Value entered is a number<br />
End If
|
|
|
|
|
hey i have a project where i need to read from a text file but i will never know how long it is. It is basically a list of numbers. I read them in and store them in a collection but how do i know when the end of file is? this is in VB.Net
|
|
|
|
|
this should help , make sure to put your text file's location where it currently says C:\mytest.txt .
VbCode:
<font color="blue">Imports</font> System.IO <br> <font color="DarkGreen">'/// at the top of your form's code window ^^^^. <br></font> <font color="DarkGreen">'///////////////////////////////////////////// <br></font> <font color="blue">Private</font> <font color="blue">Sub</font> Button3_Click(<font color="blue">ByVal</font> sender <font color="blue">As</font> System.Object, <font color="blue">ByVal</font> e <font color="blue">As</font> System.EventArgs) <font color="blue">Handles</font> Button3.Click <br> <font color="blue">Dim</font> sReader <font color="blue">As</font> StreamReader = <font color="blue">New</font> StreamReader(<font color="blue">New</font> FileStream("C:\mytest.txt", FileMode.Open, FileAccess.Read)) <br> <font color="blue">Dim</font> x <font color="blue">As</font> <font color="blue">Integer</font> = sReader.BaseStream.Length <br> MessageBox.Show("The Length of the text file is: " & x & " Characters") <br> While Not sReader.Peek <br> Console.WriteLine(sReader.ReadLine) <br> <font color="blue">End</font> While <br> sReader.Close() <br> <font color="blue">End</font> <font color="blue">Sub</font> <br>
hope that helps
Vb:
<font color="blue">Public Function</font> TwinsOnWay(<font color="blue">ByVal</font> twins <font color="blue">As String</font>) <font color="blue">As String <br> Select Case</font> twins<br> <font color="blue">Case</font> "Gender" <br> <font color="blue">Return</font> "Two Girls" <br> <font color="blue">End Select <br> End Function</font> <br>
|
|
|
|
|
How do you "auto-scale" data points on a graph?
the data will be received at a constant frequency.
I will be receiving data from a CAN/bluetooth gateway on a vehicle.
How do I go about graphing and receiving those data points and putting them on both a line and bar graph?
Thanks.
|
|
|
|
|
Hi,
I hope someone out there may be able to help. I have a WebBrowser control written in VB 6.0 that acts a Internet viewer but with most of the normal Internet functionality removed so people can not play around with the system. This is opened by clicking on an icon that appears on a Windows shell. This has been written again to stop people moving around the Windows NT 4.0 system. when the user clicks on the viewer it opens up and displays the home page, which then asks for a login (through IIS). Once logged in an ASP page starts up and tries to get the focus, but unfortunately it is still with the underlying viewer. Is there any way to set the focus to the ASP page. The two applications are separate.
Also in VB 6.0 is there a way to get the username that is entered when IIS displays the login box. In ASP you can use ServerVariables("LOGIN_NAME"), but I don't seem to get anything back when I set this up in my code.
|
|
|
|
|
Hi,
try this with Windows XP or Window 2000:
1) create new windows application project.
2) Start debug.
3) press ctrl + Alt + Delete
4) Task manager
5) view the memory used by you application, it is 11 Mb.
And if you add a simple dbconnection with dataadatper the memory used is ~24Mb.
Is there a way to reduce the memory used by the application?
In my application with simple 5 form it use 75 Mb of memory.
It is too much. confused:
Max
|
|
|
|
|
The task manager shows your working set, which isn't the same as the memory load of your process. The .NET Framework is included in that lot, as well as anything else which happens to be shared. Try pview for more accurate stats.
--
Ian Darling
|
|
|
|
|
Contrary to popular belief, automaticall memory management in .Net is not equivalent to 100% total resource clean up. Coders still have the responsability of freeing some resources through the Dispose() method.
Use dispose whenever available if you want to reduce memory footprint and avoid thoses cases where Net programs' memory usage continuously grows over time. (A five form program should never reach 75 Mb (unless it deals with very large quantities of data like uncompressed 20MB+ images) if coding practices are good.
Also, try minimizing the form in your example and see how much memory it is using (much less). This happens because at startup your program is assigned a large working set to account for any initialization the CLR and associated dlls might need.
|
|
|
|
|
i made an audio program
But i need a function that tells me if the current audio contains music ..
that to provide my application more features
Really i need ur help
thanks alot
ahmed elmahdy
|
|
|
|
|
elmahdy wrote:
But i need a function that tells me if the current audio contains music
What sort of audio are you using? mp3, wav, wma?
Then is there any meta-data associated with that format to indicate if it's music or something else (eg, audiobook or sample)
AFAIK there's no simple way to tell if something is music or not (I'm guessing some sort of analysis to detect repeating beats?) - and writing software that does this requires musical expertise and usually costs $£€
--
Ian Darling
|
|
|
|
|
i use wav sort
i want to display a sweety things when my program find music ... i will deal with sound ports ??
what is the best method ?
thanks alot
ahmed elmahdy
|
|
|
|
|
elmahdy wrote:
what is the best method ?
I don't know. The scope of your question is outside what this forum is aimed at, and I'm not a music expert. Try searching on google?
--
Ian Darling
|
|
|
|
|
How can I get txtbox1.Text and txtbox2.Text data into the same array, without hand-coding the values into a separate arra y???
|
|
|
|
|
(VB.NET) Try a Datagrid and using data binding on the array instead if you have a lot of textboxes?
(VB6) Use a control array, and then you can use a loop to copy across to the array.
YMMV
--
Ian Darling
|
|
|
|
|
I have 12 textboxes that I need as one array,12 others as a separate array.
I think the datagrid might work, but I've never used that control. Can you point me to an article (beginner level).
Thanks for your help!
|
|
|
|
|
Well, there's probably an article on CP somewhere, but it's really simple - bung a datagrid on your form, then call SetDataBinding on it with your array:
' Example - display an array of 3 items in a datagrid
Dim myArray as String(3) = { "Hi", "Hello", "Bonjour" }
' Haven't tested this, but should work ok
DataGrid1.SetDataBinding(myArray, "")
If you need something more complicated (eg, multiple columns), use a DataTable instead of an Array. All of this is documented in MSDN anyway.
--
Ian Darling
|
|
|
|
|
This is my first time here, so: hi guys! Hope your day does not suck. Mine is OK, but I'm banging my fragile head against a problem with converting UNIX standard epoch numbers to something fairly regular, date-wise.
I receive a timecode from a Perl program, written as seconds since 1970, the standard way of talking about time in the UNIX world. Then my VB component wants to log this thing, and well, I'd like to be able to record it like YYYY-MM-DD HH:MM, but so far I am stumped.
Some gotchas (add to this list if you can come up with more difficulties that could crop up during the writing of such a function):
* leap years
A few examples of timecodes from the last few weeks:
1054746806
1054555725
1056715898
OK, that is my question. Have you done this before?
Have a nice day, folks.
Olle
Lund, Sweden
|
|
|
|
|
After doing a nice function to calculate how many seconds have elapsed since 1970-01-01 00:00:00 a workmate came by and whistled that I should do a DateDiff()
<br />
DateDiff("s", CDate("1970-01-01 00:00:00"), Now)<br />
Which was correct. Sigh. I'll try and make the other conversion, now. From seconds into days and years and months and...
See you.
Olle,
Shamed in a corner, Lund, Sweden
|
|
|
|
|
I believe this will work, but I didn't actually test it against any known Epoch date values.
Private Function GetEpochDate(ByVal seconds As Long) As DateTime<br />
Dim BeginningOfTime As New DateTime(1970, 1, 1)<br />
Return BeginningOfTime.AddSeconds(seconds)<br />
End Function
|
|
|
|
|
I regret that I am now working with VB6, and I'm also sorry I didn't include that into my first posting. I bow my head in shame. DateAdd() is my next stop, I guess.
Yep, it was!
<br />
Public Function GetEpochToDate(ByVal seconds As Long) As Date<br />
GetEpochDate = DateAdd("s", seconds, CDate("1970-01-01 00:00:00"))<br />
End Function<br />
Public Function GetDateToEpoch(ByVal theDate As Date) As Long<br />
GetDateToEpoch = DateDiff("s", CDate("1970-01-01 00:00:00"), theDate)<br />
End Function<br />
Thank you, Matt!
|
|
|
|
|
|
I want to access active web page objects like text boxes from VB application. I know it could be done using ActiveX. Can anyone help me How To Do It.
AJC
|
|
|
|
|
Hello,
I need some sound advice, here is the scenario: I have a mdiChild form that contains a button that launches a owned (owned by the mdiChild) form. My questions is: What is the most effective way to pass data from the owned form to the appropriate member variables declared on the mdiChild form (owner)?
Thanks in advance,
Andrew
|
|
|
|
|
It's alright I figured it out. I created a custom constructor for the owned form that accepts an instance of the mdiChild form.
Example:
(Owned Form Declaration)
Public Sub New(ByRef mdiChildInstance As frmMdiChild)
MyBase.New()
_mdiChildInstance = mdiChildInstance
End Sub
(OwnedForm Instantiation - code is located on the MdiChild Form)
Public OwnedForm As New frmOwnedForm(Me)
I also created public properties for all of the member variables on mdiChild.
Does anyone see any red flags with the code above?
Thanks,
Andrew
|
|
|
|