|
Hi,
I have a comma delimited text file. Below that
IM,ABC001,D,0,@;ABC;Images\00\00\ABC001.tif;2
IM,ABC002,,0,@;ABC;Images\00\00\ABC002.tif;2
IM,ABC003,D,0,@;ABC;Images\00\00\ABC003.tif;2
IM,ABC004,D,0,@;ABC;Images\00\00\ABC004.tif;2
I need the output as below.(In another Notepad)
"ABC001","ABC002"
"ABC003","ABC003"
"ABC004","ABC004"
It is read based on the ,D, in the input notepad. After read the ,D, we will pick the "ABC001" from after "IM". then again read the 'D' then we pick the "ABC002" from previous line. Are you not understand please see the input and output.
Please help me..
By
Gopi A.
Please help
|
|
|
|
|
Where are you stuck? What have you tried?
Seems straightforward and relatively easy.
|
|
|
|
|
They are called "text files", not "Notepads". Notepad is an application that edits text files.
Why is this so hard? It's simple string manipulation. Read the line into a String variable, split it on the "," character, then look at the 2nd element to get your name. Then look at the thrid element. If it's got a "D", then you output your name appropriately.
|
|
|
|
|
Hi Dave,
I am using this code.
My input is in notepad like below
Input:
IM,ABC001,D,0,@Box1;Images\00\00\ABC001.tif;2
IM,ABC002,,0,@Box1;Images\00\00\ABC002.tif;2
IM,ABC003,D,0,@Box1;Images\00\00\ABC003.tif;2
IM,ABC004,D,0,@Box1;Images\00\00\ABC004.tif;2
IM,ABC005,,0,@Box1;Images\00\00\ABC005.tif;2
IM,ABC006,D,0,@Box1;Images\00\00\ABC006.tif;2
output:
BegBate EndBate
ABC001 ABC002
ABC003 ABC003
ABC004 ABC005
ABC006 ABC006
After use the below code i was got only the BegBate. How I will got the Endbate also like above format?.
MY Code:
Using myreader As New Microsoft.VisualBasic.FileIO.TextFieldParser("c:\ipro.txt")
myreader.TextFieldType = FileIO.FieldType.Delimited
myreader.SetDelimiters(",")
'cr=currentrow
'cf=currentfield
Dim cr As String()
Dim count1 As Integer
While Not myreader.EndOfData
Try
cr = myreader.ReadFields()
For count1 = 4 To cr.Length - 1
If cr(2).Contains("D") Or cr(2).Contains("C") = True Then
Dim sw As StreamWriter
sw = New StreamWriter("c:\test2.txt", True, Encoding.Unicode)
sw.WriteLine(cr(1))
sw.Close()
End If
Next
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox("Line " & ex.Message & "is not valid and will be skipped.")
End Try
End While
End Using
MsgBox("completed")
Please do the needful
Very Thanks to all,
Please Help..
By
Gopi A.
|
|
|
|
|
Member 4027617 wrote: If cr(2).Contains("D") Or cr(2).Contains("C") = True Then
First, this line is incorrectly written. It just so happens that the logic works in this case. This line SHOULD read:
If cr(2).Contains("D") = True Or cr(2).Contains("C") = True Then
or
If cr(2).Contains("D") Or cr(2).Contains("C") Then
Be consistent in your code.
Now that have a case where the line contains either D or C in that field, what are you doing if it doesn't? Hint: currently, you aren't doing anything. What do you have to do if the line doesn't contain your flag characters?
|
|
|
|
|
Well, you should look up the Split method.
Like this site: Parse a string using the Split method
And also, of you searched google for "Read a comma delimited text file" you would have found many examples of how to do it without asking.
If everything was not true, would it be not true that everything is not true?
<font color="red">"Assembly.<br /> Ah, yes that dreaded thing that pulled itself out of the abyss. <br />-- Wait, assembly is not that bad. It just takes time to adjust to."</font>
|
|
|
|
|
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@partNumber",
I cant find a way to access a sql parameter from a dataset from the insertcommand. Is there a way through the partial class to access this information.
|
|
|
|
|
A DataSet is disconnected from the database. It has no knowledge of how it got its data or how the data potentially gets sent to the database, or even what database it comes from or goes to, or even if there is any database at all!
Man who stand on hill with mouth open wait long time for roast duck to drop in
|
|
|
|
|
How we can check folder read/write or full control permissions using VB6.0?
Thanks.
|
|
|
|
|
Are you trying to find out if a particular person has permissions before writing to a file or what?? Why are you doing this?? Maybe there is another way besides trying to get the ACL for a folder.
|
|
|
|
|
FileSystem.GetAttr("C:\here") = vbReadOnly
You don't get very much more.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
hi
Previously I was using frmStart as my startup object and in Form_Load I was calling LinkExecute if my frmStart is already loaded.
Now I have changed my startup object and using Sub Main() to show or hide frmStart.
Problem is that now when I call LinkExecute in the frmStart Load the execution goes fine but Object gets unloaded automatically. I get Error '364'
After LinkExecute I have Unload Me command but control never reaches there.
please tell me how to avoid the "Object was unloaded" error.
Thanks.
|
|
|
|
|
I have no clue what you're talking about...
Is this a VB6 app or VB.NET?? What are you doing with "LinkExecute"?? on what object is it being called?? What's the complete error message you're getting??
|
|
|
|
|
please see following details:
public Sub Main()
If App.PrevInstance Then
If Command$ <> vbNullString Then
myform.HiddenText.Text = Command$
myform.HiddenText.LinkTopic = "MyApplication|SendCmd"
myform.HiddenText.LinkMode = vbLinkManual
myform.HiddenText.LinkExecute myform.HiddenText.Text
myform.HiddenText.LinkMode = vbLinkNone
End If
Unload myform
Exit Sub
Else
'perform some checks
End If
'pseudo code
If checks are not valid
show message and exit
else
if command$ has value
myform.show
else
myform.hide
end if
end if
Exit sub
End Sub
Now in this case i get "Timeout while waiting for DDE response".
Please reply.
modified on Monday, June 15, 2009 12:39 AM
|
|
|
|
|
I couldn't tell you. I haven't touched VB6 in over 8 years now. Sorry.
|
|
|
|
|
Hi CP,
i am using the custom font to hide the properties
Public Class MyCustomFont
Inherits FontConverter
Public Overrides Function GetPropertiesSupported(ByVal context As System.ComponentModel.ITypeDescriptorContext) As Boolean
Return False
End Function
End Class
Now i want to hide the Script : ComboBox which exists in the bottom of the FONT Dialog .
how can i implement in this code ??
Regards ,
|
|
|
|
|
I don't know if this is what you are looking for or not. This doesn't make the combobox disappear completely, but it gets rid of all of the choices except for the default.
Dim myFont As New FontDialog
myFont.AllowScriptChange = True
myFont.ShowDialog()
Hope that helps.
-Ray
|
|
|
|
|
Public Class MyCustomFont
Inherits FontConverter
Public Overrides Function GetPropertiesSupported(ByVal context As System.ComponentModel.ITypeDescriptorContext) As Boolean
Return False
End Function
End Class
<Category("Appearance")> <Description("The font used to display text in the control")> _
<TypeConverter(GetType(MyFont))> _
Public Property Font() As Font
Get
Return _Font
End Get
Set(ByVal Value As Font)
_Font = Value
End Set
End Property
I am showing the FONT in this way in the propertygrid . While showing the FONT Dialog then the Script Combobox should not be shown .
Regards
|
|
|
|
|
I am reading an excel sheet into datatable. in excel sheet one column has values like (70,1) instead of decimal "," is used as decimal seperator.
i want to change the "," into "." in the table without looping each row for that column. one way is to set the culture but that doesnt change the value of the data already in the table.
is there a way of changing the values of columns
|
|
|
|
|
I imagine the answer is probably that the data should be stored as numbers, so that it reflects the current culture when it is read in. I think there may be a tryParse that takes a culture, so you could convert from the known source culture, put in the table as double, and then let the system display it correctly ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
another way is setting the culture and then changing it
Dim dt As New DataTable
Dim myCultureInfo As New System.Globalization.CultureInfo("nb-NO")
dt.Locale = myCultureInfo
dt.Columns.Add("T", System.Type.GetType("System.Decimal"))
Dim dr As DataRow
dr = dt.NewRow
dr(0) = "70,1"
dt.Rows.Add(dr)
dr = dt.NewRow
dr(0) = "80,1"
dt.Rows.Add(dr)
Dim myCultureInfo1 As New System.Globalization.CultureInfo("en-US")
dt.Locale = myCultureInfo1
|
|
|
|
|
Im looking for some help;
I have a windows application devekoped. In vb.net
I have a crystal report viewer for displaying my reports, I have various different report forms which use this viewer.
My problem is that the export button defaults to a .rpt extension , and I need it to default to .xls
I have come across the exportoptions class and created a button using this, but this exports as soon as button is hit.
I want the exact same functionality as you get for the standard export button, I just don’t want the default save as to be ‘rpt’, I want it to be ‘xls’ and still allow the user to changes their export type, probably involving the SaveFiledialog component
Prob is.. I have no idea how its done.. anyone got any ideas or better some code. Id really appreciate help on this.
|
|
|
|
|
I have a program that does something similar, but I always export to PDF. I don't think there is a way to set the default file extension of the export button on the viewer. You need to hide the button on the crystal reports viewer and create your own version of the button in order to do what you are asking. In order to export it, you need to use the ExportToDisk method on the ReportDocument object, not the Viewer. You don't actually even need a crystal reports viewer object to export a report, only to display it to the user.
|
|
|
|
|
Ooops, I meant to comment about the dialog too. Drag a Save Dialog box control onto your form, to set the default file extension you would do something like this:
'This sets default settings on a save dialog called dlgExport
With dlgExport
.Filter = "Excel Files (*.xls)|*.xls|All Extensions (*.*)|*.*"
.FilterIndex = 1
.RestoreDirectory = True
.Title = "Export"
.AddExtension = True
.FileName = String.Empty
End With
'This is what you would put in the export button's click event:
If dlgExport.ShowDialog = Windows.Forms.DialogResult.OK Then
'You probably want to add checks to make sure dlgExport.FileName is valid first
reportDocument1.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel, dlgExport.FileName)
End If
|
|
|
|
|
Works Perfect! Thank you.
|
|
|
|
|