|
I've been looking all over for the answer to this, and I'm apparently too dense today to implement the various solutions I've found. It seems this should be simple...
I have a config file that looks like this:
KZZZ (City2)|KZZZ-FM|...other values
KQQQ (City1)|KQQQ-AM|...other values
Right now there are only 2 values for each line, but I want the flexibility to add fields in the future. I want to read this file into an Array(ish Collection) and then sort it based on the second column.
Here's the code so far...
' set up needed variables
Dim ConfigFileReader As IO.StreamReader = New IO.StreamReader(My.Settings.DataRoot & My.Settings.StationConfigFileName)
Dim Configline, ConfigFields() As String
Dim ConfigDelimiter() As Char = {Convert.ToChar("|")}
Dim LineCount, FieldCount As Integer
Dim InsertLine As String = Nothing
' read in 1st line
Configline = ConfigFileReader.ReadLine
' parse line, placing each field into StationList array
Do Until Configline = Nothing
ConfigFields = Configline.Split(ConfigDelimiter)
For FieldCount = 0 To UBound(ConfigFields)
StationList(LineCount, FieldCount) = ConfigFields(FieldCount)
Next
' resize array to the right width
ReDim Preserve StationList(999, FieldCount)
' increment counters, read next line
LineCount += 1
FieldCount = 0
Configline = ConfigFileReader.ReadLine
Loop
End Sub
The issues:
I don't like declaring the oversize array (initialized as 999,1). Seems like an ArrayList would be the solution, but I'm not getting how to make a multi-dimensional ArrayList.
I'm apparently too dense today to implement a "sort on the second field" routine.
Thanks for your help!
Scott
|
|
|
|
|
+don't use an arraylist use generic list (of)
+Create a class that implements 'IComparer' this will allow you to specify how you want the list sorted.
'declare the list
Dim oaFuncInfo as new list(of FuncInfo)
'populate the list
Dim oFunc as New FuncInfo
oFunc.sFunc = sFunc
oFunc.sStatus = sStatus
oFunc.sComment = sComment
oaFuncInfos.Add(oFunc)
'sort the list: the reason for the (new funcinfo) is because I am using the same class for the sorting instead of using a different class that implements the icomparer
oaFuncInfos.Sort(New FuncInfo)
'The Class:
Friend Class FuncInfo
Implements IComparer(Of FuncInfo)
Public sFunc As String
Public sStatus As String
Public sComment As String
'define how how want to sort
Public Function Compare(ByVal x As FuncInfo, ByVal y As FuncInfo) As Integer Implements System.Collections.Generic.IComparer(Of FuncInfo).Compare
If x.sFunc < y.sFunc Then
Return -1
ElseIf x.sFunc = y.sFunc Then
Return 0
Else
Return 1
End If
End Function
End Class
|
|
|
|
|
I'm trying to pass multiple DataKeynames after a selection is made in the Gridview, and to view them in a DataList where the selection matches them. Right now it will only display the first selected parameter (jacket).
Here is my code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" Visible="false"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" DataKeyNames="jacket, closure, shielding" ForeColor="Black" GridLines="Vertical" Width="750px" OnPageIndexChanging="gridViewPublishers_PageIndexChanging" OnSorting="gridViewPublishers_Sorting"
AllowPaging="True" PageSize="20" AllowSorting="True" PagerSettings-Mode="NumericFirstLast">
<FooterStyle BackColor="#CCCCCC" />
<Columns>
<asp:CommandField ItemStyle-Width="70" ShowSelectButton="True" />
<asp:BoundField ItemStyle-Width="130" DataField="partnumber" HeaderText="Partnumber" ReadOnly="True" SortExpression="partnumber" />
<asp:BoundField ItemStyle-Width="100" DataField="jacket" HeaderText="Jacket" SortExpression="jacket" />
<asp:BoundField ItemStyle-Width="220" DataField="closure" HeaderText="Closure" SortExpression="Closure" />
<asp:BoundField ItemStyle-Width="110" DataField="shape" HeaderText="Shape" SortExpression="shape" />
<asp:BoundField ItemStyle-Width="130" DataField="shielding" HeaderText="Shielding" SortExpression="Shielding" />
</Columns>
<SelectedRowStyle BackColor="#7c7979" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#CCCCCC" />
<PagerSettings Mode="NumericFirstLast" />
</asp:GridView><br /><br />
<asp:DataList ID="DataList1" runat="server" BackColor="#1679d5" BorderColor="#999999"
BorderStyle="Solid" BorderWidth="1px" CellPadding="3"
ForeColor="White" GridLines="Vertical" DataSourceID="SqlDataSource1" Visible="false">
<FooterStyle BackColor="#CCCCCC" />
<SelectedItemStyle BackColor="Blue" Font-Bold="False" ForeColor="White" />
<ItemTemplate>
<table>
<tr>
<td style="width:120px; font-weight:bold;">
<asp:Label ID="materialLabel" runat="server" Text='<%# Eval("material") %>' />
</td>
<td style="width:450px;">
<asp:Label ID="Label" runat="server" TabIndex="1" Text='<%# Eval("marketing_tagline") %>' />
</td>
<td style="width:150px; text-align:center;">
<div class="SearchDataLink">
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("material", "dataSheet.aspx?id={0}") %>' TabIndex="2" Target="_blank" Text="View datasheet" />
</div>
</td>
</tr>
</table>
</ItemTemplate>
<AlternatingItemStyle BorderWidth="1" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ZippertubingConnectionString %>" SelectCommand="SELECT * FROM [ProductVerbage] WHERE ([material] = @jacket) OR ([material] = @closure) OR ([material] = @shielding) " >
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="jacket" PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="GridView1" Name="closure" PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="GridView1" Name="shielding" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
|
|
|
|
|
This question belongs in the ASP.NET forum. It's got nothing to do with VB.NET.
|
|
|
|
|
I Need A Complete Article About SMO .
Plz Help me.
|
|
|
|
|
Google for "SMO" and see what you get.
|
|
|
|
|
Hi everyone,
In the ASP page, I store the output (in the form of html strings) from the rich-text editor in a database; when time comes, I retrieve the required HTML string (I use VB as a server-side language) (htmlCode variable.) The I wish to pass this htmlCode to some JavaScript function:
<body onload="populateWithHTML('<%=htmlCode%>')">
BUT! Here is the problem. This html string can contain " (quote) and ' (apostrophe) symbols, that break the resulting HTML.
How should I fix this? Thank you much in advance!
-------------------------
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
|
server.htmlencode is a .NET method; is there a way to make it in a ordinary (non-.NET) VB and ASP?
-------------------------
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
check again. server.HTMLEncode exists in ASP.
|
|
|
|
|
Oops! Thanks a lot.
BTW, is there a server.HTMLDecode method?
-------------------------
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
No problem.
No there isn't such a function.
|
|
|
|
|
i am generating report using dataenvironment in VB using ODBC -oracle database server.
The report contains some 25 columns ,VB reports an error that "Report width is larger than the page size"
how to fix this problem.
|
|
|
|
|
align the page setup and do not allow any entry in adviced page layout, if there is any entry, remove it. It will work
|
|
|
|
|
Hi. I have a form with various textboxes, comboboxes and a datagridview. The datagridview and textboxes are bound to the same datasource and if i enter information into either the textboxes or the datagridview the information is updated to the database correctly. The datatable that they are bound to is called "song". the problem I have is that I want the user to only be allowed to select specific "genres" that are stored in a "genre" table. so i want the combobox to display the values from this "genre" table and when he selects a value the datagridview "genre" field is updated for the "song" table. then later on i want the user to be able to select a genre(on a different form) and all songs per genre are listed. can anyone help me with this? Simple solution? thanks in advance
Mr Oizo
|
|
|
|
|
Hi there,
Through coding i'm creating a xml file. In this manually i'm creating some node eg: "<Field>". Now what's happening is, it's automatically creating xmlns value as: "<Field xmlns="">". But i don't want that. Please help me.
How to remove xmlns value. I don't want that.
Regards n Thks
Sam.M
|
|
|
|
|
Well, that would depend entirely on how you're generating this XML file. Without seeing the code, it's impossible to tell you how to do it.
|
|
|
|
|
In vb.net I use the following:
Dim ns As New XmlSerializerNamespaces
ns.Add("", "")
'empty strings required to prevent default namespace declarations appearing in xml file
|
|
|
|
|
Hi All,
I saw various option in this thrade and come to solve my own solution for remove xmlns attribute in xml. This is working properly and no any issue with this--->
'Remove the Equifax / Transunian / Experian root node attribute that have xmlns and load xml without xmlns attributes.
If objXMLDom.DocumentElement.NamespaceURI <> String.Empty Then
objXMLDom.LoadXml(objXMLDom.OuterXml.Replace(objXMLDom.DocumentElement.NamespaceURI, ""))
objXMLDom.DocumentElement.RemoveAllAttributes() ResponseXML = objXMLDom.OuterXml
End If
Therefor no need to do any thing else to remove xmlns from xml
|
|
|
|
|
hi,i have created one project its working fine on my machine but when it is installed on some other machine it gives the error Loading report failed because i am loading my reports dynamically through code and i have specified the address of local machine(i.e. d drive).Tell me how te get the path of report file so that i dont have to specify the path manually.
Thanx.
GIRISH
|
|
|
|
|
ShuklaGirish wrote: hi,i have created one project its working fine on my machine but when it is installed on some other machine it gives the error Loading report failed because i am loading my reports dynamically through code and i have specified the address of local machine(i.e. d drive).Tell me how te get the path of report file so that i dont have to specify the path manually.
Thanx.
GIRISH
Maybe you can try specifying the path of the report as relative to where your application is?
|
|
|
|
|
Depending on where your report is stored relative to your app's .EXE file, you might want to start with something like this:
Dim appPath As String = Application.StartupPath
Dim reportPath As String = Path.Combine(appPath, "somereport.rpt")
' Load your report from the path in "reportPath".
|
|
|
|
|
sorry sir
but i cannot find any forum for vb6.0 here...
plz suggest some remedy for my problem...
how to use the line continuation character in vb6.0 when u r going to write a update query in a string which goes more than 1024 characters(max allowed.)
ex.
strsql="update table set fld1='" & txt1 & "', _
fld2='" & txt2 & "' where id='" & myId & "'"
this gives me the error "end of statement expected...."
plz give me the exact syntax....
|
|
|
|
|
I think the _ needs to be the last character. You can't just put & at the end ? Wow - VB6 really sucks...
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
MissionSuccess wrote: how to use the line continuation character in vb6.0 when u r going to write a update query in a string which goes more than 1024 characters(max allowed.)
ex.
strsql="update table set fld1='" & txt1 & "', _
fld2='" & txt2 & "' where id='" & myId & "'"
Probably better to split into two Update queries...
|
|
|
|