• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

Check for a Blank space in a text

How can I check that if my FeatureComment is not a text or numeric value then I just leave it as a blank space.
objStreamWriter.WriteLine(_partfile.PartfileData(intloop).FeatureName.PadRight(10, " "c) & " " & "-" & " " & _partfile.PartfileData(intloop).FeatureType.PadRight(5, " "c) & " " & "-" & " " & _partfile.PartfileData(intloop).FeatureComment)
                        objStreamWriter.WriteLine(_partfile.PartfileData(intloop).FeatureName.PadRight(10, " "c) & " " & "X" & " " & _partfile.PartfileData(intloop).X.ToString("0.000").PadLeft(11, " "c) & _partfile.PartfileData(intloop).X.ToString("0.000").PadLeft(11, " "c) & " " & _partfile.PartfileData(intloop).X.ToString("0.000").PadLeft(10, " "c) & " " & _partfile.PartfileData(intloop).X.ToString("0.000").PadLeft(10, " "c))
                        objStreamWriter.WriteLine("          " & " " & "Y" & " " & _partfile.PartfileData(intloop).Y.ToString("0.000").PadLeft(11, " "c) & _partfile.PartfileData(intloop).Y.ToString("0.000").PadLeft(11, " "c) & " " & _partfile.PartfileData(intloop).Y.ToString("0.000").PadLeft(10, " "c) & " " & _partfile.PartfileData(intloop).Y.ToString("0.000").PadLeft(10, " "c))
                        objStreamWriter.WriteLine("          " & " " & "Z" & " " & _partfile.PartfileData(intloop).Z.ToString("0.000").PadLeft(11, " "c) & _partfile.PartfileData(intloop).Z.ToString("0.000").PadLeft(11, " "c) & " " & _partfile.PartfileData(intloop).Z.ToString("0.000").PadLeft(10, " "c) & " " & _partfile.PartfileData(intloop).Z.ToString("0.000").PadLeft(10, " "c))
                        objStreamWriter.WriteLine("          " & " " & "D" & " " & PointList.Item(intloop).D_value.ToString("0.000").PadLeft(11, " "c) & _partfile.PartfileData(intloop).Nominal.ToString("0.000").PadLeft(11, " "c) & " " & _partfile.PartfileData(intloop).USL.ToString("0.000").PadLeft(10, " "c) & " " & _partfile.PartfileData(intloop).LSL.ToString("0.000").PadLeft(10, " "c))

Open in new window

0
cmdolcet
Asked:
cmdolcet
2 Solutions
 
CodeCruiserCommented:
You can use many of the string functions such as String.IsNullOrEmpty or String.Contains etc
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
_partfile.PartfileData(intloop).FeatureComment.Trim() ???
0
 
Jacques Bourgeois (James Burger)PresidentCommented:
Assuming that FeatureComment is a String:

Add the following before your code:
Dim featureComment As String
If _partfile.PartfileData(intloop).FeatureComment.Length>0 then
    featureComment = " " & "-" & " " & _partfile.PartfileData(intloop).FeatureComment
EndIf

Open in new window

Then change your code to use the featureComment variable instead of what you have actually:

objStreamWriter.WriteLine(_partfile.PartfileData(intloop).FeatureName.PadRight(10, " "c) & " " & "-" & " " & _partfile.PartfileData(intloop).FeatureType.PadRight(5, " "c) & featureComment)
                        objStreamWriter.WriteLine(_partfile.PartfileData(intloop).FeatureName.PadRight(10, " "c) & " " & "X" & " " & _partfile.PartfileData(intloop).X.ToString("0.000").PadLeft(11, " "c) & _partfile.PartfileData(intloop).X.ToString("0.000").PadLeft(11, " "c) & " " & _partfile.PartfileData(intloop).X.ToString("0.000").PadLeft(10, " "c) & " " & _partfile.PartfileData(intloop).X.ToString("0.000").PadLeft(10, " "c))
                        objStreamWriter.WriteLine("          " & " " & "Y" & " " & _partfile.PartfileData(intloop).Y.ToString("0.000").PadLeft(11, " "c) & _partfile.PartfileData(intloop).Y.ToString("0.000").PadLeft(11, " "c) & " " & _partfile.PartfileData(intloop).Y.ToString("0.000").PadLeft(10, " "c) & " " & _partfile.PartfileData(intloop).Y.ToString("0.000").PadLeft(10, " "c))
                        objStreamWriter.WriteLine("          " & " " & "Z" & " " & _partfile.PartfileData(intloop).Z.ToString("0.000").PadLeft(11, " "c) & _partfile.PartfileData(intloop).Z.ToString("0.000").PadLeft(11, " "c) & " " & _partfile.PartfileData(intloop).Z.ToString("0.000").PadLeft(10, " "c) & " " & _partfile.PartfileData(intloop).Z.ToString("0.000").PadLeft(10, " "c))
                        objStreamWriter.WriteLine("          " & " " & "D" & " " & PointList.Item(intloop).D_value.ToString("0.000").PadLeft(11, " "c) & _partfile.PartfileData(intloop).Nominal.ToString("0.000").PadLeft(11, " "c) & " " & _partfile.PartfileData(intloop).USL.ToString("0.000").PadLeft(10, " "c) & " " & _partfile.PartfileData(intloop).LSL.ToString("0.000").PadLeft(10, " "c))
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now