|
It WORKS... yayyyy.. if i put empty textbox it will put 0 to my table... THANK YOU A LOT my code would be like this ...
Dim C1S As String = DirectCast(row.FindControl("Label1"), TextBox).Text
Dim C1 As Integer = 0
Integer.TryParse(C1S, C1)
Can u pls explain to me how it works? I think i sleep with a smile on my face tonite.. Its 12midnite rite now at my place... I've been building this prgm learning to do it by google.. Cannot find anyone to teach so i turn to Google.. But when this error come out... I cannot find the solution in google... THANK YOU AGAIN
|
|
|
|
|
zaimah wrote: It WORKS..
Whehe, well done - read both posts after another.
zaimah wrote: Can u pls explain to me how it works?
The first instruction finds the control, casts it to a textbox, gets it's value from the Text-property and assigns it to a new variable with the name C1S. That's a whole lot of responsibilities on a single line.
The second line declares a new variable (of the integer type) and assigns '0' to it.
The third line then tries to assign a number to C1, based on the text that's in C1S.
zaimah wrote: <layer>I think i sleep with a smile on my face tonite..
Rightly so
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
try
if DirectCast(row.FindControl("Label1"), Textbox).Text is Nothing then
'Skip here
End If
Catch ex as exception
'It's Empty move to another control
end try
Hope this helps the idea is to check for a value before trying to use it.
|
|
|
|
|
hi, i have a problem of Index was outside the bounds of the array. i don't understand how to amend the existing solution in my case. anyone could help me? the message error is System.IndexOutOfRangeException {"Index was outside the bounds of the array. Below is the code & the error is at sixth last line(strTextOut = arrMicrosensor(intNum).strCode)
Public Function sensorWithinRange() As MicrosensorStruct()
Dim arrMicrosensor() As MicrosensorStruct '
Dim dblNearestStation As MicrosensorStruct '
Dim intStationCounter As Integer 'Counter for stations
Dim dblStationE As Double 'Easting coords of one station
Dim dblStationN As Double 'Northing coords of one station
Dim intNearestSensor As Integer '
Dim strNearestSensor() As String '
Dim intA, intB, IntMaxIndex As Integer '
Dim dblMaxValue As Double '
Dim sMax, sTemp As MicrosensorStruct '
Dim strTextOut As String '
Dim strArrColumns() As String 'Columns within 1 station record
Dim chrArrDelim() As Char = " ,".ToCharArray() 'File delimiter
Dim sReader As IO.StreamReader
Dim strRecord As String
intStationCounter = -1
intNearestSensor = 0
dblStationE = CDbl(txtEasting.Text)
dblStationN = CDbl(txtNorthing.Text)
sReader = IO.File.OpenText(txtFilename.Text)
strRecord = sReader.ReadLine()
strRecord = sReader.ReadLine()
Do While (Not sReader.EndOfStream)
strRecord = sReader.ReadLine()
intStationCounter = (intStationCounter + 1)
Loop
sReader.Close()
Dim intNrStations As Integer 'Total number of station
ReDim arrMicrosensor(intNrStations)
sReader = IO.File.OpenText(txtFilename.Text)
strRecord = sReader.ReadLine()
dblNearestStation.dblRngeDist = Double.PositiveInfinity
For intStationCounter = 0 To intNrStations - 1
strRecord = sReader.ReadLine()
strArrColumns = strRecord.Split(chrArrDelim)
arrMicrosensor(intStationCounter).lngID = CLng(strArrColumns(0))
arrMicrosensor(intStationCounter).strOUTCORP = strArrColumns(1)
arrMicrosensor(intStationCounter).strCode = strArrColumns(2)
arrMicrosensor(intStationCounter).dblNorthing = CDbl(strArrColumns(3))
arrMicrosensor(intStationCounter).dblEasting = CDbl(strArrColumns(4))
arrMicrosensor(intStationCounter).dblRngeDist = CalculateDistance(dblStationN, dblStationE, arrMicrosensor(intStationCounter).dblNorthing, arrMicrosensor(intStationCounter).dblEasting)
If arrMicrosensor(intStationCounter).dblRngeDist &lt; CDbl(txtRangeDist.Text) Then
intNearestSensor = intNearestSensor + 1
'string for text in listbox
lboNearestStation.Items.Add("STATION ID:" &amp; arrMicrosensor(intStationCounter).lngID.ToString &amp; " , " _
&amp; "REFERENCE CODE:" &amp; arrMicrosensor(intStationCounter).strCode &amp; " , NORTHING:" _
&amp; arrMicrosensor(intStationCounter).dblNorthing.ToString("F") &amp; ", EASTING:" _
&amp; arrMicrosensor(intStationCounter).dblEasting.ToString("F") &amp; ", at:" _
&amp; arrMicrosensor(intStationCounter).dblRngeDist.ToString("F") &amp; "m")
End If
Next intStationCounter
sReader.Close()
ReDim strNearestSensor(intNearestSensor - 1)
For intStationCounter = 0 To intNrStations - 1
If arrMicrosensor(intStationCounter).dblRngeDist &lt; CDbl(txtRangeDist.Text) Then
intNearestSensor = 0
strNearestSensor(intNearestSensor) = arrMicrosensor(intStationCounter).strCode
End If
Next
Dim intNum As Integer
intNum = CInt(txtNrSensor.Text)
'For intNum = 0 To intNum - 1
For intNum = 0 To intNum - 1
For intA = arrMicrosensor.GetUpperBound(0) To 1 Step -1
sMax = arrMicrosensor(0)
dblMaxValue = sMax.dblRngeDist
IntMaxIndex = 0
For intB = 0 To intA
If arrMicrosensor(intB).dblRngeDist &gt; dblMaxValue Then
dblMaxValue = arrMicrosensor(intB).dblRngeDist
IntMaxIndex = intB
End If
Next intB
sTemp = arrMicrosensor(intA)
arrMicrosensor(intA) = arrMicrosensor(IntMaxIndex)
arrMicrosensor(IntMaxIndex) = sTemp
Next intA
strTextOut = arrMicrosensor(intNum).strCode
Next intNum
Return arrMicrosensor
End Function
modified 13-Oct-12 1:40am.
|
|
|
|
|
For intNum = 0 To intNum - 1
What do you expect to happen when the index reaches -1?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I'm a hobbyist programmer, and sometimes I go many months without programming. I have recently come back to a project I started months ago, and I am confused by my own (working) code.
Here's the code that is confusing me:
Dim groupToAdd As DavisGroup
groupToAdd = Aggregate g In groupList Into FirstOrDefault(g.Name = newGroupName)
The variable groupList is a ListOf(DavisGroup). The code is testing to see whether the list already contains an object with the Name (String property of DavisGroup) "newGroupName" as the names have to be unique. My code goes on to do something different depending on if groupToAdd is a returned object or is Nothing. What I don't get is what "Aggregate" is doing.
In trying to search for an answer, I rewrote the same code like this:
groupToAdd = groupList.FirstOrDefault(Function(g) g.Name = newGroupName)
As far as I can tell, this code works in exactly the same way.
My questions:
What is Aggregate doing in this particular snippet?
Are these two snippets equivalent?
If so, is there a reason to prefer one over the other?
|
|
|
|
|
|
Employee ID :
Customer ID :
Order Date :
Shipped Date :
Shipper ID :
Ship Name :
Ship Address :
Ship City :
Ship State/Province :
Ship ZIP/Postal Code :
Ship Country/Region :
Shipping Fee :
Taxes :
Payment Type :
Paid Date :
Notes :
Tax Rate :
Tax Status :
Status ID :
<%
Dim Employee_ID, Customer_ID, Order_Date, Shipped_Date, Shipper_ID, Ship_Name,
Ship_Address, Ship_City, Ship_State_Province, Ship_ZIP_Postal_Code, Ship_Country_Region,
Shipping_Fee, Taxes, Payment_Type, Paid_Date, Notes, Tax_Rate, Tax_Status, Status_ID
Dim sConnString, connection, sSQL
Employee_ID=Request.Form("Employee_ID")
Customer_ID=Request.Form("Customer_ID")
Order_Date=Request.Form("Order_Date")
Shipped_Date=Request.Form("Shipped_Date")
Shipper_ID=Request.Form("Shipper_ID")
Ship_Name=Request.Form("Ship_Name")
Ship_Address=Request.Form("Ship_Address")
Ship_City=Request.Form("Ship_City")
Ship_State_Province=Request.Form("Ship_State_Province")
Ship_ZIP_Postal_Code=Request.Form("Ship_ZIP_Postal_Code")
Ship_Country_Region=Request.Form("Ship_Country_Region")
Shipping_Fee=Request.Form("Shipping_Fee")
Taxes=Request.Form("Taxes")
Payment_Type=Request.Form("Payment_Type")
Paid_Date=Request.Form("Paid_Date")
Notes=Request.Form("Notes")
Tax_Rate=Request.Form("Tax_Rate")
Tax_Status=Request.Form("Tax_Status")
Status_ID=Request.Form("Status_ID")
sSQL = "INSERT INTO Orders (Employee_ID, Customer_ID, Order_Date, Shipped_Date,
Shipper_ID, Ship_Name, Ship_Address, Ship_City, Ship_State_Province,
Ship_ZIP_Postal_Code, Ship_Country_Region, Shipping_Fee, Taxes, Payment_Type, Paid_Date,
Notes, Tax_Rate, Tax_Status, Status_ID) Values (" & Employee_ID & ", " & Customer_ID & ",
#" & Order_Date & "#, #" & Shipped_Date & "#, " & Shipper_ID & ", '" & Ship_Name & "', '"
& Ship_Address & "', '" & Ship_City & "', '" & Ship_State_Province & "', '" &
Ship_ZIP_Postal_Code & "', '" & Ship_Country_Region & "', '' & Shipping_Fee & '', '' &
Taxes & '', '" & Payment_Type & "', #" & Paid_Date & "#, '" & Notes & "', '" & Tax_Rate &
"', '" & Tax_Status & "', '" & Status_ID & "')"
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath
("/database/Examen.mdb")
Set connection = Server.CreateObject("ADODB.Connection")
connection.Open(sConnString)
connection.execute(sSQL)
response.write "The form information was inserted successfully."
connection.Close
Set connection = Nothing
%>
I have an HTML Form that request various data types and I keep getting the following error:
Microsoft JET Database Engine error '80040e10'
No value given for one or more required parameters.
/ordersconnection3.asp, line 32
It's a Microsoft Access Database. Any help will be appreciated.
|
|
|
|
|
It looks like you could be passing a null value to one of your columns. I would check that out first.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
I've tripled checked that all the Allow Zero Length field are on NO. Is there anything else I should be looking out for? Does the syntax look accordingly even for the currency field?
|
|
|
|
|
Does the sql string built above, with all the parameters, run from within the Access query builder?
|
|
|
|
|
I work for an ISP strictly for small business and minimal residential. We provide different services as well as web hosting. We have to convert web domains to an IP once a month from a list.
I am trying to recreate an app in VB.net and it takes forever for ping result to come back as true or flase and when I transl;ate the host into an IP it doesnt get an IP for the host even though it exists. Here is a sample picture of my compiled app running:
http://postimg.com/87000/what-86552.jpg[^]
my code in vb.net:
Imports System
Imports System.Net
Imports System.IO
Public Class Form1
Dim reachable As Boolean = False
Dim IPEntry As IPHostEntry
Dim ReadAllLinesArray() As String
Public Function IsDestinationRechable(ByVal hostOrAddress As String)
Try
reachable = My.Computer.Network.Ping(hostOrAddress)
Catch pingException As System.Net.NetworkInformation.PingException
Catch genericNetworkException As System.Net.NetworkInformation.NetworkInformationException
End Try
Return reachable
End Function
Public Sub GetPingAndIPv4()
Try
For Each s As String In ReadAllLinesArray
Try
IPEntry = Dns.GetHostByName(s)
If IsDestinationRechable(IPEntry.AddressList(0).ToString) = True Then
Dim lsv As ListViewItem = lsvHostItemList.Items.Add(s)
lsv.SubItems.Add(IPEntry.AddressList(0).ToString)
lsv.SubItems.Add(IsDestinationRechable(reachable))
tssProgressBar.PerformStep()
Else
Dim lsv As ListViewItem = lsvHostItemList.Items.Add(s)
lsv.SubItems.Add("n/a")
lsv.SubItems.Add(IsDestinationRechable(reachable))
tssProgressBar.PerformStep()
End If
Catch ex As Exception
End Try
Next
Catch ex As Exception
End Try
End Sub
Private Sub OpenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OpenToolStripMenuItem.Click
If OpenOldHostsFile.ShowDialog = Windows.Forms.DialogResult.OK Then
ReadAllLinesArray = File.ReadAllLines(OpenOldHostsFile.FileName)
tssProgressBar.Maximum = ReadAllLinesArray.Count
End If
End Sub
Private Sub SaveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem.Click
If SaveNewHostsFile.ShowDialog = Windows.Forms.DialogResult.OK Then
End If
End Sub
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
Private Sub RunToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles RunToolStripMenuItem1.Click
GetPingAndIPv4()
End Sub
My code isn't complete I am trying to get the main functionality working correctly first.
|
|
|
|
|
The most common is your DNS infrastructure is taking forever to resolve the host name passed into the Ping method. There are anyn number of reasons for this, none which have anything to do with your code.
Also, the default timeout for Ping to wait for a response is half a second, so I hope you don't mean that takes forever.
|
|
|
|
|
I managed to figure out why, my next question is, why is my code not returning the IP and saying the site site is in active, and also when it returns an IP I type that IP in the browser and it doesn't take me to the domain that its assigned to. why? I guess I could see this as a security prevention but how do I get the right IP from it?
|
|
|
|
|
All of this comes down to a screwed up DNS system. None of this is because of your code.
If you give the DNS system host name and it returns the wrong IP, unless you're the administrator of the DNS system, there's nothing you can do about it.
Either the correct IP is returned, or some proxy server for the browser to use is returned, or the data doesn't go to the correct machine.
The other thing is that Ping is NOT a viable method for determining if a host is available or not. This is because firewalls may be between you and the host, blocking ICMP traffic or the host may be ignoring all ICMP traffic, even though the server and its web site are up and running and responding.
|
|
|
|
|
Knowing I dont have the admin access what would be the viable method without seeming I am a threat to any system. If ICMP isnt going to work then how else would I go about converting the hostname into an IP using the best methods?
|
|
|
|
|
Without a known good authoritative DNS that knows about the target system you have no options. The only thing you need the DNS for is to resolve the hostname to an IP or the other way around. If you don't have a good DNS, you have no hope of matching up hostnames to IPs.
ICMP is the protocol that Ping uses, not DNS. Ping sends an ICMP packet to the hostname or IP specified and waits for a response. If it gets one within the timeout period, the host is considered alive by Ping.
If not, this is in no way an indication that the host is unavailable or down. It just means the packet either never got to the host because of a firewall blocking it (getting more and more common) or it's passing through some hop that filters out ICMP.
Internally, Ping uses DNS to resolve a specified hostname to an IP. You can only talk to IP addresses, not hostnames. If DNS is wrong or not working properly, the Ping will be wrong too.
|
|
|
|
|
Perhaps a far-fetched alternative, but at least it's another option;
You could setup OpenDNS[^] on a remote machine, and have that convert the IP to a host-name (using a webservice or whatever type of communication). You'd call the <a href="http://msdn.microsoft.com/en-us/library/sbetxfzt.aspx">Dns.GetHostByAddress</a>[<a href="http://msdn.microsoft.com/en-us/library/sbetxfzt.aspx" target="_blank" title="New Window">^</a>] -member, and return the host-name.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hello. I have this small COM component which I added to my project using 'Add Reference'. Now when I tried to generate delegates from this component, I get this error.
<br />
An error occured creating the form. The error is: Public member 'FunctionName()' on type 'MyComponentName' not found <br />
Here is what I am trying
public sub Constructor()
private objName as New Component()
objName.OnFunctionCall = new COM_Component_OnFunctionCallEventHandler(AddressOf OnFunctionCall)
end sub
public sub OnFunctionCall()
end sub
What could be wrong? Thanks for any input.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
public sub Constructor()
Dim objName as New Component()
objName.OnFunctionCall = new COM_Component_OnFunctionCallEventHandler(AddressOf OnFunctionCall) // delegate
end sub
public sub OnFunctionCall() // my delegate
MsgBox "Test"
end sub
The Private keyword is used if you declare your variable outside of a method, inside the method you'd typically use the Dim keyword.
In VB, you use the '-character to denote a comment, // are for C# and will not work in VB. See the difference with the syntax-highlighting above.
Naming the method 'Constructor' doesn't make it one. Use the VB-syntax if you need an actual constructor. It's something like 'Sub New' or similar.
For your question; it would seem that the class 'MyComponentName' does not have a method with specified signature. You are instantiating something else than MyComponentName ; you created a new Component[^], and that's an existing animal that does not have a OnFunctionCall member.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hi. Thanks for the reply. I am still stuck on it. What is the difference between the method shown previously and the method I am trying below
Public Class ABC
Private objName as New Component()
Public Sub New()
AddHandler objName.OnFunctionCall, AddressOf OnFunctionCall
End Sub
Public Overridable Sub OnFunctionCall()
MessageBox.Show("asd")
End Sub
End Class
However it is giving me this exception
<br />
An unhandled exception of type 'system.stackoverflowexception' occured in 'mscorlib.dll'<br />
What could be wrong with my understanding till now?
This world is going to explode due to international politics, SOON.
|
|
|
|
|
AmbiguousName wrote: What is the difference between the method shown previously and the method I am trying below
Most major difference is that objName is now a class member, no longer a variable within the constructor. Also changed, you now have the correct constructor.
The Component is an EXISTING control, one that gets not instantiated because it's one of the base-controls; also, note it does not have a member called "OnFunctionCall".
I'm going to guess that you'd want to instantiate your own class. For that, you'd have to define it first, something like this;
Public Class MyThingy
End Class
Public Class ABC
Private Thingy as New MyThingy()
Public Sub New()
AddHandler objName.OnFunctionCall, AddressOf OnFunctionCall
End Sub
Public Overridable Sub OnFunctionCall()
MessageBox.Show("asd")
End Sub
End Class
"OnFunctionCall" does not exist in the Thingy-class here, but it looks like that's what you'd want. Or is there a special reason for using "Component"?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: "OnFunctionCall" does not exist in the Thingy-class here, but it looks like that's what you'd want.
Yes.
- But first I want OnFunctionCall() to be triggered in class ABC, which happens to be a virtual function also.
- Same function will be called in MyThingy since MyThingy a child class of ABC.
Eddy Vluggen wrote: Or is there a special reason for using "Component"?
Just learning it.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
This would be inheritance;
Public Class MyThingy : Inherits ABC
Public Overrides Sub OnFunctionCall()
MsgBox "Hello Universe!!"
End Sub
End Class
Public Class ABC
Public Sub New()
End Sub
Public Overridable Sub OnFunctionCall()
MessageBox.Show("Hello world!")
End Sub
End Class
Which is different from embedding a class;
Public Class MyThingy
Public Event EventHandler OnMyFunction
Private Sub TriggerEvent()
OnMyFunction(Me, EventArgs.Empty)
End Sub
End Class
Public Class ABC
Private Thingy as MyThingy()
Public Sub New()
Thingy = New MyThingy
AddHandler Thingy.OnMyFunction, AddressOf LocalOnMyFunctionImplementation
End Sub
Public Overridable Sub LocalOnMyFunctionImplementation(Object as Sender, e As EventArgs)
MessageBox.Show("asd")
End Sub
End Class
AmbiguousName wrote: Just learning it.
Enjoy
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Dear all,
The following script is not reading the xml data and translating it into the graph.
The output is currently showing a blank webpage, and I am not sure why is?
<BODY>
<%
Dim oRs, oRs2, strQuery
Dim strXML
Set oRs = Server.CreateObject("ADODB.Recordset")
strXML = "<graph caption='Deals Output report' subCaption='By Quantity' decimalPrecision='0' showNames='1' numberSuffix=' Units' pieSliceDepth='30' formatNumberScale='0'>"
strQuery = "select * from deal_price2"
Set oRs = oConnection.Execute(strQuery)
While Not oRs.Eof
Set oRs2 = Server.CreateObject("ADODB.Recordset")
strQuery = "select sum(price) as TotOutput from deal_price where deal_id=" & ors("deal_id")
Set oRs2 = oConnection.Execute(strQuery)
strXML = strXML & "<set name='" & ors("date") & "' value='" & ors2("TotOutput") & "' />"
Set oRs2 = Nothing
oRs.MoveNext
Wend
strXML = strXML & "</chart>"
Response.Buffer=true
response.write strXML
response.flush
Set oRs = nothing
Call renderChart("MyWeb/includes/FCF_Line.swf", "", strXML, "FactorySum", 650, 450)
%>
Any help would be very much appreciated.
Thanks in advance for your help.
|
|
|
|
|