|
I am trying to edit the decimal part of a number so if a person enters
40.25
i can chane it to
40.375
but i need it to work with any whole number any ideas?
I was thinking i could use:
dim a as decimal
dim b as integer
dim c as decimal
a = textbox1.text
b = textbox1.text
if a - b = .25 then
c = b + .375
textbox2.text = c
I wished we used the metric system in the US would make my like easy
1. Out of clutter, find simplicity.
2. From discord, find harmony.
3. In the middle of difficulty lies opportunity.
Albert Einstein
three rules of work
|
|
|
|
|
What about using "mod" to get the remainder then working with that?
mod = Divides two numbers and returns only the remainder.
For Example:
40 mod 1 = 0
40.25 mod 1 = .25
So you could write something like this to get the decimal(remainder) part of any number entered:
dim d as single = input mod 1
if d = .25 then
'do something
end if
|
|
|
|
|
I am working on a mortgage calculator program in VB.net. I have created it and can input loan amount, interest rate, term and get what the monthly payment will be. The next thing I need to do is allow it to list the new loan amount and interest paid for each period of the term of the loan. I think I need to use a loop and since it will display 15 years of payments and results I need it to display partial list, hesitate, then display more of the list. I have placed a list box and am trying to get the result for the first monthly payment to subtract from the total loan amount and then display the new amount in the list box. I need help in writing the loop that will allow this to occur. Can someone help me out with this? Here is where I am now
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
'Calculate the Monthly Payment'
Dim dblAmount As Double
Dim dblMonthlyRate As Double
Dim dblMonths As Double
Dim dblMonthlyPayment As Double
'Convert input values to numeric values'
dblAmount = CDbl(txtAmount.Text)
dblMonthlyRate = CDbl(txtRate.Text) / 100 'allows interest rate to be entered whole number'
dblMonths = CDbl(txtYears.Text)
'Format input values'
txtAmount.Text = FormatCurrency(dblAmount)
txtRate.Text = FormatPercent(dblMonthlyRate)
txtYears.Text = FormatNumber(dblMonths)
'Calculate payment'
dblMonthlyPayment = -Pmt(dblMonthlyRate / 12, dblMonths * 12, dblAmount)
'Format answer'
txtMonthlyPayment.Text = FormatCurrency(dblMonthlyPayment)
'Results for listbox should be new loan balance and interest rate'
'Result should be from Loan Amount minus result in Payment field'
'Dim dblLoanInterest As Double
'Dim i As Integer
'Dim NewLine As String
'dblLoanInterest = CDbl(lstLoanInterest.Text)
'dblLoanInterest = dblAmount - dblMonthlyPayment
End Sub
|
|
|
|
|
I've spent quite a lot of man hours investigating how to save the contents of my axWebBrowser to an image in VB.NET. I've tried using BitBlt but that only saves what's been rendered to the screen, so if the web page is scrollable and not all visible it doesn't capture all of it. I tried using the HTML Element; render to DC; all that stuff, but to no avail. I was pointed to a free, downloadable executable (iecapt.exe) which does a good job of capturing a url to an image. However, if the url is generic and isn't a direct reflection of the web page viewed it does me no good.
If anyone has any suggestions I would be forever grateful,
Thanks in advance
Ben
|
|
|
|
|
Hi Everybody,
I have a directory filled with files which are all exactly 1000 bytes big. What I need to do is simply to read the files in a stream one by one and to write them again in a different directory. I'd say this is a fairly standard operation, but for some reason, all my files come out of the process at 1001 bytes!! Am I missing something? Here is my code:
For Each f As IO.FileInfo In inDirInfo.GetFiles()
Dim str As New IO.FileStream(f.FullName, IO.FileMode.Open, IO.FileAccess.Read)
Dim chunk(str.Length) As Byte
str.Read(chunk, 0, chunk.Length)
str.Close()
Dim chunkStream As New IO.MemoryStream(chunk)
WriteStream(chunkStream, outputTempPath & "\" & f.Name)
chunkStream.Close()
Next
Private Sub WriteStream(ByVal stream As IO.Stream, ByVal path As String)
Try
Dim f As New IO.FileStream(path, IO.FileMode.Create)
Dim bytes(stream.Length) As Byte
stream.Read(bytes, 0, bytes.Length)
stream.Close()
f.Write(bytes, 0, bytes.Length)
f.Close()
Catch ex As Exception
Throw ex
End Try
End Sub
By the way, I don't want to simply copy the files, since I need to transfer them in streams.
Thanks for your help...
|
|
|
|
|
Ok, nevermind... I was missing something
Here is the corrected code:
For Each f As IO.FileInfo In inDirInfo.GetFiles()
Dim str As New IO.FileStream(f.FullName, IO.FileMode.Open, IO.FileAccess.Read)
Dim chunk(str.Length - 1) As Byte
str.Read(chunk, 0, str.Length)
str.Close()
Dim chunkStream As New IO.MemoryStream(chunk)
WriteStream(chunkStream, outputTempPath & "\" & f.Name)
chunkStream.Close()
Next
Private Sub WriteStream(ByVal stream As IO.Stream, ByVal path As String)
Try
Dim f As New IO.FileStream(path, IO.FileMode.Create)
Dim bytes(stream.Length - 1) As Byte
stream.Read(bytes, 0, stream.Length)
stream.Close()
f.Write(bytes, 0, bytes.Length)
f.Close()
Catch ex As Exception
Throw ex
End Try
End Sub
|
|
|
|
|
hii
got one prob when i m trying to transfer the ASP.NET Web Application (which i ve basically done fully only on on computer) to another comp.
when we try to open this application on some other comp, it does not open n shows error... so i would like to know wat is that we r missing,in copying the file or is it something else ??
and the other comp on which we are trying to open this application is working properly for ASP.NET Web Applications...
hope my prob ll be solved..
thanks
|
|
|
|
|
Gee, it sure would help if you told us what the error was.
Is IIS pointing to the right directory ? Does the target machine have the .net framework installed ? Was it installed after IIS ( so that IIS knows about ASP.NET ) ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thanks...
the prob got solved.. but still the Web Application is not getting debugged...
this is the error i got while debugging any asp.net application on VB.NET
**************************************************************
Error while trying to run project: Unable to start debugging on the web server. Server side error occured on sending debug HTTP request
Make sure the server is operating corerclty. Verify that there are no syntax errors in Web.config by doing a Debug, Start without Debugging.
***********************************************************
i tried the start without debugging option but its working properly there... cant get wat the exact prob is ??
AND..
also when i open the Microsoft Visual Stdio.NET..n see the Debug--->Process.. i dont find the aspnet_wp.exe there.. is there any prob in the .NET Framework >??
i think that is the prob... but not sure how to sort it out ??
|
|
|
|
|
I've had this in the past, and I found an article on MSDN that showed me how to fix it. I recommend googling your error message in quotes, you're bound to find the solution that way.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How can I change the design of report at run time through VB.NET code? is it possible? actuallu I want to create an application where users can set their own report desigh.
|
|
|
|
|
hello
how can I assign null value to date field? date field can be null in DB
|
|
|
|
|
thnx i got it
its dbnull.value
|
|
|
|
|
I'm trying to bind a picture box to my access 2003 Db in vb.net
Here is my code
Dim b As Binding = New Binding("Image", dsComics, "comiclist.ComicCover")<br />
AddHandler b.Format, AddressOf ConvertPicture<br />
Me.picCover.DataBindings.Add(b)<br />
<br />
<br />
<br />
Public Sub ConvertPicture(ByVal Sender As Object, ByVal e As ConvertEventArgs)<br />
Dim b() As Byte = e.Value<br />
Dim ms As MemoryStream = New MemoryStream<br />
ms.Write(b, 0, b.Length)<br />
Dim bmp As Bitmap = New Bitmap(ms)<br />
ms.Close()<br />
e.Value = bmp<br />
<br />
<br />
End Sub
The line in bold is where it bombs, any ideas
BINARY
|
|
|
|
|
'use to save image file
Dim arr() As Byte
FileOpen(1,"FilePath" , OpenMode.Binary, OpenAccess.Read, OpenShare.Shared)
'Resize array so that it can accomodate the file
ReDim arr(FileLen("FilePath") - 1)
FileGet(1, arr)
FileClose(1)
'use to read image file
arr = ds.Tables("TableName").Rows(0).Item("ColumnName")
'comapny logo is the name of PictureBox control
CompanyLogo.Image = CompanyLogo.Image.FromStream(New IO.MemoryStream(arr))
|
|
|
|
|
I tried that and it bombed here:
picCover.Image = picCover.Image.FromStream(New IO.MemoryStream(arr))
might it be a problem with access?
|
|
|
|
|
use Dataset to retrieve and save image
I am using following lines .there is no error
arr = ds.Tables("CompanyInfo").Rows(0).Item("CompanyLogo")
CompanyLogo.Image = CompanyLogo.Image.FromStream(New IO.MemoryStream(arr))
there is also an article with demo project(using access) is available in this group. try to search with keyword "Image"
|
|
|
|
|
ok I'll try it thanx
BINARY
|
|
|
|
|
nope nothing, If any one could build a sample to show me where I'm going wrong. I've heard something about header information in the field.
BINARY
|
|
|
|
|
I have a program, it has two thread.
The second thread listen to the network and accept the request, the code is below. And the main thread write messages to the client connected every one minute; how can I write to all the clients connect in the main thread? Do I need some change in the code below?
thanks
Public Sub Listen()
Dim Appreader As System.Configuration.AppSettingsReader
Appreader = New System.Configuration.AppSettingsReader
While blistener
Dim localEndPoint As New IPEndPoint(System.Net.IPAddress.Parse( _
Appreader.GetValue("localAddr", GetType(System.String))), _
Appreader.GetValue("localPort", GetType(System.String)))
Listener = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Try
Listener.Bind(localEndPoint)
Listener.Listen(10)
While True
Console.WriteLine(Chr(10) + "等待连接中...")
' Program is suspended while waiting for an incoming connection.
Listener.Accept()
Console.Write(Chr(10) + "连接!")
End While
Catch ex As Exception
End Try
End While
|
|
|
|
|
i m trying to stream media files on VB.NET interface using Windows Media Player component.. but its not being played..
well, i hav tried embedding the windows media player component on the WebApplication.....it is appearing on the client side but it is not able to play any files...... and we are not able to even select any controls provided in the player...
we are using Windows 2000 Advanced Server as OS.
actually we dont ve much idea about how streaming takes place on the internet and do we need to add any other codec or component to achieve Media Streaming ???
waiting for replies.
thanks..
|
|
|
|
|
|
If this is your "VB Client" app for you "media server", why are you using a web app? You never said anything about that before... All you need to do is include a link to the video file on the server, in URL form. The client side will take care of the rest when the user clicks on the link.
And yes, I gave you a 1 on this question. I don't live here at CP. I have a life and like to spend alot of time with her. So that means I can, and WILL, disappear from CP whenever I want, leaving your questions unanswered if you direct them at me.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
I have a life and like to spend alot of time with her
Did you mean wife ? Or are the two synonymous ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
She isn't yet! In May of next year, she will be!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|