Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Problem with Format function

I have the following line of code in my add-in.

obj.textbox1.value = format(Date)

I find that the format function often produces inconsistent results, i.e.
sometimes it produces null strings. Anyone know why?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Problem with Format function

Not sure what you wabt Date to look like but try this
format's date as 061407
Format(Date, "[$-409]mmddyy;@")

"TimK" wrote:

I have the following line of code in my add-in.

obj.textbox1.value = format(Date)

I find that the format function often produces inconsistent results, i.e.
sometimes it produces null strings. Anyone know why?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Problem with Format function

I tried that and it still gives me null strings.

"Mike" wrote:

Not sure what you wabt Date to look like but try this
format's date as 061407
Format(Date, "[$-409]mmddyy;@")

"TimK" wrote:

I have the following line of code in my add-in.

obj.textbox1.value = format(Date)

I find that the format function often produces inconsistent results, i.e.
sometimes it produces null strings. Anyone know why?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Problem with Format function

Post what you have

"TimK" wrote:

I tried that and it still gives me null strings.

"Mike" wrote:

Not sure what you wabt Date to look like but try this
format's date as 061407
Format(Date, "[$-409]mmddyy;@")

"TimK" wrote:

I have the following line of code in my add-in.

obj.textbox1.value = format(Date)

I find that the format function often produces inconsistent results, i.e.
sometimes it produces null strings. Anyone know why?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Problem with Format function

Here is an edited excerpt of my code:

Public gate As Boolean
Public formtype As Boolean
Public r1, c1, col, row As Integer
Const sTblPrefix = "=[ODCmgt.xla]DataFields!"
Sub newpar()
'
' this is called when the NEW PAR button is clicked
'
Dim z As Long
Dim rng As Range
x1Down = -4121
Dim mydate As Date

r1 = ActiveCell.Cells.row 'save where cursor is in spreadsheet
c1 = ActiveCell.Cells.Column
..
..
..
If Cells(2, 1).Value = Empty Then ' if this is the first par to
enter
ActiveSheet.Cells(2, 1).Select ' set focus
Cells(2, 1).Value = 1 ' set par #
GoTo skp ' and get on with it
End If
Range("A1").End(x1Down).Select ' jump to last format(row,0,0,0) in
spreadsheet
z = ActiveCell.Cells.row + 1 ' calc next empty line's column
ActiveCell.Offset(1, 0).Select 'jump the cursor there
skp: col = 1 ' save location of new line's
coordinates
row = ActiveCell.Cells.row
Load NewPARForm ' load the form first
'Init the controlsource properties for the new spreadsheet line
With NewPARForm
.TextBox1.ControlSource = address(col, row)
If ActiveCell.Value < 1 Then
z = Cells(row - 1, col).Value + 1
.TextBox1.Value = z 'init w/ next sequential par#
End If
ActiveCell.Offset(0, 1).Select 'Move cursor to the product field
.ComboBox1.SetFocus ' need to move cursor to cell
.ComboBox1.ControlSource = address(col + 1, row)
.TextBox3.ControlSource = address(col + 2, row)
.ComboBox2.ControlSource = address(col + 3, row)
.TextBox5.ControlSource = address(col + 4, row)
.TextBox5.Value = Format(Date, "[$-409]mmddyy;@") ' initialize the
date entered field <<<------------------------------
.ComboBox3.ControlSource = address(col + 5, row)
.ComboBox4.ControlSource = address(col + 6, row)

The indicated line is where I tried your suggestion. Whey I ran this with a
breakpoint at the following line, the .Textbox5.value field showed "" as its
content.

"Mike" wrote:

Post what you have

"TimK" wrote:

I tried that and it still gives me null strings.

"Mike" wrote:

Not sure what you wabt Date to look like but try this
format's date as 061407
Format(Date, "[$-409]mmddyy;@")

"TimK" wrote:

I have the following line of code in my add-in.

obj.textbox1.value = format(Date)

I find that the format function often produces inconsistent results, i.e.
sometimes it produces null strings. Anyone know why?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Problem with Format function

Not sure try this
.TextBox5.Value = Format(Address(col + 4, row), "[$-409]mmddyy;@")

"TimK" wrote:

Here is an edited excerpt of my code:

Public gate As Boolean
Public formtype As Boolean
Public r1, c1, col, row As Integer
Const sTblPrefix = "=[ODCmgt.xla]DataFields!"
Sub newpar()
'
' this is called when the NEW PAR button is clicked
'
Dim z As Long
Dim rng As Range
x1Down = -4121
Dim mydate As Date

r1 = ActiveCell.Cells.row 'save where cursor is in spreadsheet
c1 = ActiveCell.Cells.Column
.
.
.
If Cells(2, 1).Value = Empty Then ' if this is the first par to
enter
ActiveSheet.Cells(2, 1).Select ' set focus
Cells(2, 1).Value = 1 ' set par #
GoTo skp ' and get on with it
End If
Range("A1").End(x1Down).Select ' jump to last format(row,0,0,0) in
spreadsheet
z = ActiveCell.Cells.row + 1 ' calc next empty line's column
ActiveCell.Offset(1, 0).Select 'jump the cursor there
skp: col = 1 ' save location of new line's
coordinates
row = ActiveCell.Cells.row
Load NewPARForm ' load the form first
'Init the controlsource properties for the new spreadsheet line
With NewPARForm
.TextBox1.ControlSource = address(col, row)
If ActiveCell.Value < 1 Then
z = Cells(row - 1, col).Value + 1
.TextBox1.Value = z 'init w/ next sequential par#
End If
ActiveCell.Offset(0, 1).Select 'Move cursor to the product field
.ComboBox1.SetFocus ' need to move cursor to cell
.ComboBox1.ControlSource = address(col + 1, row)
.TextBox3.ControlSource = address(col + 2, row)
.ComboBox2.ControlSource = address(col + 3, row)
.TextBox5.ControlSource = address(col + 4, row)
.TextBox5.Value = Format(Date, "[$-409]mmddyy;@") ' initialize the
date entered field <<<------------------------------
.ComboBox3.ControlSource = address(col + 5, row)
.ComboBox4.ControlSource = address(col + 6, row)

The indicated line is where I tried your suggestion. Whey I ran this with a
breakpoint at the following line, the .Textbox5.value field showed "" as its
content.

"Mike" wrote:

Post what you have

"TimK" wrote:

I tried that and it still gives me null strings.

"Mike" wrote:

Not sure what you wabt Date to look like but try this
format's date as 061407
Format(Date, "[$-409]mmddyy;@")

"TimK" wrote:

I have the following line of code in my add-in.

obj.textbox1.value = format(Date)

I find that the format function often produces inconsistent results, i.e.
sometimes it produces null strings. Anyone know why?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Format Problem - Date Overrides Format Mary Excel Discussion (Misc queries) 5 February 10th 10 05:49 AM
General Format to Custom format problem KELC-F/A Excel Discussion (Misc queries) 1 May 2nd 08 09:51 PM
how do you write format results of a function within a function? sangee Excel Worksheet Functions 3 June 14th 07 12:45 AM
Problem with format function in excel VBa Camper Joe Excel Worksheet Functions 1 October 12th 06 12:42 PM
Problem with function format Steve Excel Worksheet Functions 2 December 27th 04 01:43 PM


All times are GMT +1. The time now is 07:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"