|
that easy!!! omg.. sorry for the dumb question
|
|
|
|
|
- You crack me up, Dude.
Hey, the only dumb question is the one you should have asked and didn't, right?
|
|
|
|
|
Ah hell now i came to another bottleneck... um (feels very stupid) how can i use this to display the actual total size of a drive because so far i can get it to say 16Bytes when it should be saying 250GB (well in that region)
|
|
|
|
|
Try something like this:
Dim dr As New System.IO.DriveInfo("C")
Dim sizeInBytes As Long
Dim sizeInGB As Single
sizeInBytes = dr.TotalSize
sizeInGB = sizeInBytes / 1000000000
TextBox1.Text = String.Format("Total Drive Size in Bytes: {0}", sizeInBytes.ToString("#,###,###,###,###"))
TextBox2.Text = String.Format("Total Drive Size in GB: {0}", sizeInGB.ToString("###,###,###,###.00"))
You can play around with the verbage, divisor value, and formatting as you prefer.
|
|
|
|
|
Yes!! thanks so much for this golden nugget i been searching for something like this for ages whew
THANK YOU!!
|
|
|
|
|
You're welcome!
(I gotta go do some nasty work for a while now. Fighting an 8-headed datagrid monster.
Catch ya later. Happy coding.)
|
|
|
|
|
Hey guys, I'm writing this program for a visual basic class I'm taking in college, but I can't seem to figure this out.
I have a function wrote by it passes some day ByRef, it gives me the right anwser, but I showed it to my teacher and she said I need to change it to ByVal, but when I do that it gives me an anwser of 0.
So does anyone know how I'd be able change the function to ByVal and still give me the right anwser?
Thanks
What I'm trying to change is "Function CalcOwed(ByVal Number As Double, ByRef Data As Double) As Double" to "Function CalcOwed(ByVal Number As Double, ByVal Data As Double) As Double".
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim TaxIncome, Amount, Count As Double
lstDisplay.Items.Clear()
Input(TaxIncome, Amount)
Display(Amount)
End Sub
Sub Input(ByRef TaxIncome As Double, ByRef Amount As Double)
TaxIncome = CDbl(InputBox("Enter your taxable income", , ""))
If TaxIncome > 0 Then
CalcOwed(TaxIncome, Amount)
Else
Do While TaxIncome <= 0
TaxIncome = CDbl(InputBox("Enter your taxable income, above zero this time", , ""))
Loop
CalcOwed(TaxIncome, Amount)
End If
End Sub
Sub Display(ByVal Amount As Double)
lstDisplay.Items.Add("You owe " & (FormatCurrency(Amount)))
End Sub
Function CalcOwed(ByVal Number As Double, ByRef Data As Double) As Double
Select Case Number
Case 1 To 7150
Data = Number * 0.1
Case 7150 To 29050
Data = (Number * 0.15) + 715
Case 26050 To 70350
Data = (Number * 0.25) + 4000
Case 70350 To 146750
Data = (Number * 0.28) + 14325
Case 146750 To 319100
Data = (Number * 0.33) + 35717
Case Else
Data = (Number * 0.35) + 92595.5
Return Number
End Select
Return Number
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
lstDisplay.Items.Clear()
End Sub
End Class
|
|
|
|
|
The reason she wants you to change it to ByVal is to see if you understand the difference between passing arguments by value and passing them by reference. Obviously, you don't yet. You just skimmed over that section in the book, and you can't do that. This key point is fundamental to just about all programming languages, not just VisualBasic.
We could just show you how to change it and make it "give the right answer", but that would doing you and the industry a grave disservice.
So go back to your book, find that section, and re-read it. Several times if necessary.
This may also help.
Visual Basic Language Concepts
Differences Between Passing an Argument By Value and By Reference
http://msdn2.microsoft.com/en-us/library/eek064h4(VS.80).aspx[^]
Hint 1:
ByRef gives your procedure code a direct view back to the original variable.
ByVal gives your procedure code a COPY of, and an indirect view of, the VALUE of the original variable.
Hint 2: Why code a Function if you are just going to call it as a Sub and not use the return value from it?
|
|
|
|
|
Thanks a lot for the help. =) I'll have another read over the chapter in my book, and thanks for the link.
As for coding the function, rather then just doing it all in the sub procedure, for some reason our teacher wants it done in a function. heh
Thanks again.
-- modified at 12:08 Sunday 5th November, 2006
Edit:
I got it working, thanks for all the help. =)
|
|
|
|
|
Excellent. Good work!
|
|
|
|
|
I want to know how to calculate the balance in the list box
[code]
Option Explicit
Private msngPrice As Single
Private Sub Form_Load()
Dim prstCustomerName As String
Open "C:\CustomerName.txt" For Input As #1
Do Until EOF(1) = True
Input #1, prstCustomerName
List1.AddItem prstCustomerName
Loop
Close #1
End Sub
Private Sub List1_Click()
Dim prstName As String
Dim name As String
Dim pdate As Date
Dim pintRec As Integer
Dim pintInv As Integer
'Dim pintRec As Integer
Dim prstCustomerName As String
Dim pdblCredit As Double
Dim pdblDebit As Double
Dim pdblBalance As Double
Dim psngBalance As Single
List2.Visible = True
Label1.Visible = False
Label2.Visible = True
Label3.Visible = True
Label4.Visible = True
Label5.Visible = True
Label6.Visible = True
Label7.Visible = True
Label8.Visible = True
name = InputBox("Enter the customer name", "Write", List1)
Open "C:\" + name + ".txt" For Input As #1
Do Until EOF(1) = True
Input #1, pintInv, prstCustomerName, pdate, pdblDebit
List2.AddItem pdate & vbTab & pintInv & vbTab & vbTab & vbTab & prstCustomerName & vbTab & Format(pdblDebit, "##,###,###.00")
Loop
Close #1
name = InputBox("Enter the customer name", "Write", List1)
Open "C:\" + name + "1" + ".txt" For Input As #2
Do Until EOF(2) = True
Input #2, pintRec, prstCustomerName, pdate, pdblCredit
'pdblCredit = List2.ListIndex = 1
'pdblBalance = List2.ListIndex = 1
List2.AddItem pdate & vbTab & vbTab & pintRec & vbTab & vbTab & prstCustomerName & vbTab & vbTab & vbTab & Format(pdblCredit, "##,###,###.00") & vbTab & vbTab & Format(pdblBalance, "##,###,###.00")
pdblBalance = pdblCredit - pdblDebit + pdblCredit
Loop
Close #2
End Sub
[/code]
|
|
|
|
|
Add up all of your pdblCredit's and all of your pdblDebit 's inside your loops. Then, after the loops are done, subtract the debits from the credits and you'll have your balance.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hey guys
this is my first function in vb.net and SQL
Public Function SelectAllParts() As DataTable<br />
Dim dtPart As New SQLServer, dtPartItems As New DataTable, PartSQL As String<br />
PartSQL = "select * from Part"<br />
dtPart.SelectCommand.CommandText = PartSQL<br />
dtPart.Fill(dtPartItems)<br />
SelectAllParts = dtPartItems<br />
End Function<br />
but i Got this Error:
i have made a succesfull connection to an
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
----
any clue for that???
note that the connection test test is succeded
Regards
Ramy
|
|
|
|
|
Hi,
This is a security feature. As specified in the error you cannot connect to a remote server until such connections are enabled in the settings.
Look at the following link
http://support.microsoft.com/kb/914277[^]
Thanks !
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Hey
I took a look at this site
and now all services are running normally ( as mentionned in the site)
but i kept on facing this problem
note that ZoneAlarm(Firewall)and windows Firewall are turned off
Regards
Ramy
|
|
|
|
|
Ramy,
your function doesnt show anything about defining the connection string.
This will contain the server name, username, password, etc.
Create an SqlConnection object, pass in a connection string.
<br />
Dim cnn as New SqlConnection()<br />
cnn.ConnectionString = "Server=myserver;Database=mydatabase;User ID=myUsername; Password=myPassword;Trusted_Connection=False"<br />
Then when you create sql commands, you can pass this object in.
<br />
dim cmd as new SqlCommand("SELECT * FROM Table1;", cnn)<br />
dim adapter as new SqlDataAdapter(cmd)<br />
dim result as new Datatable()<br />
adapter.Fill (result)<br />
Hope this helps
Mark
|
|
|
|
|
when i pass parameter/ write new sql statement at run time through vb , the crystal report is not getting refreshed unless I press the refresh button on the screen printed report.
the following code gives error also
With CrystalReport1
.ReportFileName = App.Path & "\Report1.rpt"
.SelectionFormula = S ' s is a parameter
.Action = 1
End With
|
|
|
|
|
I found a user control 'generic datagrid'. i would like to use it get a calender control in one of the grid columns. how can i use it? please help
|
|
|
|
|
Sorry to make another post, but in addition to my last post, is there a way to adjust the volume for either a Sound Recording/Media Player control? Or is there a way to adjust the Windows volume?
|
|
|
|
|
UltraCoder wrote: is there a way to adjust the volume for either a Sound Recording/Media Player control?
With the windows media player control use
Player.settings.volume = IntegerValue
Have a look at the Windows Media Player SDK Technology Page[^] and download some documentation. It'll come in useful, believe me.
|
|
|
|
|
Thanks for the help and link!
|
|
|
|
|
Hi guys,
I need some help regarding windows GDI. I need your help on some errors.
1. webform1.aspx has one button
2. user press the button
3. the pic with the gdi lines will be shown(Ive create a memorystream to store the image)
4. the webform1.aspx button will b gone
Anyway where i can retain the button at webform1.aspx? Is it anyway where i can allocate a space in the webpage to display the form? OR can i use javascript to open a window where i can show the image with the GDI lines?
Tks for helping =)
|
|
|
|
|
Hey,
I just read a previous post that said something about a Sound Recording control (see here).
Anyway, I was just wondering if what that control is called in Vb.Net 2005? Does anyone know?
And, how do you get a Media Player control without the controls (play, stop etc.) at the bottom? Like the one used in Coding 4 Fun's "Non Destructive Media Edits" article? (Sorry, Coding 4 Fun took that article down, so I cannot provide a link).
Thank you!
-- modified at 0:13 Sunday 5th November, 2006
|
|
|
|
|
UltraCoder wrote: how do you get a Media Player control without the controls (play, stop etc.) at the bottom?
Add a media player control to your toolbox (as shown here[^]). Drag & drop the media player control to your form and set the uiMode property to none.
|
|
|
|
|
|