Click here to Skip to main content
15,914,481 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Formating strings in VB6 Pin
Guffa31-Oct-06 20:00
Guffa31-Oct-06 20:00 
GeneralRe: Formating strings in VB6 Pin
ChandraRam31-Oct-06 23:05
ChandraRam31-Oct-06 23:05 
QuestionHow do you set the DateTimePicker at runtime ? Pin
Shawn Owens31-Oct-06 10:03
Shawn Owens31-Oct-06 10:03 
AnswerRe: How do you set the DateTimePicker at runtime ? Pin
Dave Kreskowiak1-Nov-06 4:05
mveDave Kreskowiak1-Nov-06 4:05 
Questionaccessing data from another programs form Pin
njdnjd31-Oct-06 9:54
njdnjd31-Oct-06 9:54 
QuestionFormat number Pin
jds120731-Oct-06 9:01
jds120731-Oct-06 9:01 
AnswerRe: Format number Pin
Christian Graus31-Oct-06 9:14
protectorChristian Graus31-Oct-06 9:14 
GeneralRe: Format number Pin
jds120731-Oct-06 9:34
jds120731-Oct-06 9:34 
One thing I forgot to tell you is that the numbers that I am trying to format is coming from a file and being output to an sql database. Here is some code for you to look over just to see what is going on. I am trying to create a function and call the function in the If, Then statements.

Format Function:
Public Function FormatPartNumber(ByVal partnumber As String, ByVal formatstyle As String) As String

FormatPartNumber = String.Format(partnumber, formatstyle)

Below is one function to write the file to database and format numbers the only problem that I am having is that the number that I am trying to format will appear as XXXXX-XXX in the database instead of the actual number.

Private Sub ImportKawasakiUtilityGenerator()

Dim dttable As New DataTable
Dim row As DataRow
Dim CheckforProducts As DataTable

Dim FormattedPartnumber As String
Dim FormattedSupercedePartNumber As String


Dim Conn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Data Feeds\Current\Kawasaki\Utility Generator Only;EXtended Properties=""TeXt;HDR=No;FMT=FiXedLength"""
Dim SQLstr As String = "SELECT * FROM IMINF012.dat"
Dim da As New OleDb.OleDbDataAdapter(SQLstr, Conn)

FormattedPartnumber = vbNull
FormattedSupercedePartNumber = vbNull

da.Fill(dttable)
DataGridView1.DataSource = dttable
For Each row In dttable.Rows
CheckforProducts = ProductExist(row("itemnumber").ToString(), "3")

If Trim(row("formatcodeforitemnumber").ToString()) = "0" Or Trim(row("formatcodeforitemnumber").ToString()) = "" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XXXXX-XXX")

ElseIf Trim(row("formatcodeforitemnumber").ToString()) = "1" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XXXXX-XXX-XX")

ElseIf Trim(row("formatcodeforitemnumber").ToString()) = "2" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XXXXXX-XXXX")

ElseIf Trim(row("formatcodeforitemnumber").ToString()) = "3" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XXXXXX-XXXX")

ElseIf Trim(row("formatcodeforitemnumber").ToString()) = "4" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XXXXX-XXX-X")

ElseIf Trim(row("formatcodeforitemnumber").ToString()) = "5" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XXXXX-XXXX")

ElseIf Trim(row("formatcodeforitemnumber").ToString()) = "6" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XXXXX-XXXX-XX")

ElseIf Trim(row("formatcodeforitemnumber").ToString()) = "7" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XXXXX-X-X")

ElseIf Trim(row("formatcodeforitemnumber").ToString()) = "8" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XXXXXX-X-X")

ElseIf Trim(row("formatcodeforitemnumber").ToString()) = "9" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XXXXXX-XXXX-XX")

ElseIf Trim(row("formatcodeforitemnumber").ToString()) = "A" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XXXXXX-XXXXX")

ElseIf Trim(row("formatcodeforitemnumber").ToString()) = "B" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XXXXXX-XXXXX-XX")

ElseIf Trim(row("formatcodeforitemnumber").ToString()) = "C" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XX-")

ElseIf Trim(row("formatcodeforitemnumber").ToString()) = "D" Then
FormattedPartnumber = FormatPartNumber(row("itemnumber").ToString(), "XXX-")

End If


Hope this gives you a better idea of what I am trying to do!


jds1207
GeneralRe: Format number Pin
jds120731-Oct-06 10:27
jds120731-Oct-06 10:27 
GeneralRe: Format number Pin
Christian Graus31-Oct-06 10:49
protectorChristian Graus31-Oct-06 10:49 
GeneralRe: Format number Pin
jds12071-Nov-06 5:47
jds12071-Nov-06 5:47 
QuestionWhere are the referenced dll's?? Pin
dfense_germany31-Oct-06 8:31
dfense_germany31-Oct-06 8:31 
AnswerRe: Where are the referenced dll's?? Pin
No-e1-Nov-06 3:42
No-e1-Nov-06 3:42 
AnswerRe: Where are the referenced dll's?? Pin
Dave Kreskowiak1-Nov-06 3:53
mveDave Kreskowiak1-Nov-06 3:53 
QuestionPrinter Properties [modified] Pin
alexfromto31-Oct-06 8:17
alexfromto31-Oct-06 8:17 
QuestionProtecting your code Pin
dgibson553131-Oct-06 7:54
dgibson553131-Oct-06 7:54 
AnswerRe: Protecting your code Pin
Christian Graus31-Oct-06 8:53
protectorChristian Graus31-Oct-06 8:53 
QuestionMy form is not visible Pin
cstrader23231-Oct-06 6:06
cstrader23231-Oct-06 6:06 
AnswerRe: My form is not visible Pin
nlarson1131-Oct-06 6:16
nlarson1131-Oct-06 6:16 
GeneralRe: My form is not visible Pin
cstrader23231-Oct-06 6:31
cstrader23231-Oct-06 6:31 
GeneralRe: My form is not visible Pin
nlarson1131-Oct-06 6:41
nlarson1131-Oct-06 6:41 
GeneralRe: My form is not visible Pin
Dave Sexton31-Oct-06 19:37
Dave Sexton31-Oct-06 19:37 
GeneralRe: My form is not visible Pin
nlarson111-Nov-06 1:53
nlarson111-Nov-06 1:53 
GeneralRe: My form is not visible Pin
Dave Sexton1-Nov-06 4:17
Dave Sexton1-Nov-06 4:17 
QuestionForm not visible Pin
cstrader23231-Oct-06 5:52
cstrader23231-Oct-06 5:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.