目前我设法开发了一种字母数字ID。但我尝试运行几次,发现有时数字值只会显示4位数(假设没有输入一个0)所以我缺少一个代码来帮助我使它达到5位数,任何一个心灵给我那段黄金代码?感谢
这是我当前的代码
Private Sub Workbook_Open() ' Called every time you open the Excel document
Dim alpha As String
Dim numeric As Long
Dim alphanumeric As String
Randomize
numeric = CLng(Rnd() * 99999) ' CLng converts the floating point number to a long integer
alpha = "SCC"
alphanumeric = alpha & numeric
Dim rowNum As Integer
Dim colNum As Integer
rowNum = 6
colNum = 4
With ThisWorkbook.Sheets("Sheet1").Cells(rowNum, colNum)
If (.Value = "") Then
.Value = alphanumeric
End If
End With
End Sub
答案 0 :(得分:6)
更改此行代码
viewWillAppear
到
alphanumeric = alpha & numeric
答案 1 :(得分:4)
替换
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class = "table table-bordered table-responsive ">
<thead>
<tr>
<th>Segment</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<input type="hidden" name="user_id" value="user_id">
<td class="segment" contenteditable="true">segment1</td>
<td class="text-center">
<button class = "btn btn-default action-btn" data-id="id1" data-action="update">
<span class = "glyphicon glyphicon-edit"></span> Update
</button>
|
<button class = "btn btn-success activate-btn action-btn" data-id="id1" id="id1-activate" type="submit" data-action="activate">
<span class = "glyphicon glyphicon-check"></span> Activate
</button>
<button style="display:none" class = "btn btn-danger deactivate-btn action-btn " data-id="id1" id="id1-deactivate" data-action="deactivate">
<span class = "glyphicon glyphicon-folder-close"></span> deactivate
</button>
</td>
</tr>
<tr>
<input type="hidden" name="user_id" value="user_id">
<td class="segment" contenteditable="true">segment2</td>
<td class="text-center">
<button class = "btn btn-default action-btn" data-id="id2-update" data-action="update">
<span class = "glyphicon glyphicon-edit"></span> Update
</button>
|
<button class = "btn btn-success activate-btn action-btn" data-id="id2" id="id2-activate" type="submit" data-action="activate">
<span class = "glyphicon glyphicon-check"></span> Activate
</button>
<button style="display:none" class = "btn btn-danger deactivate-btn action-btn " data-id="id2" id="id2-deactivate" data-action="deactivate">
<span class = "glyphicon glyphicon-folder-close"></span> deactivate
</button>
</td>
</tr>
</tbody>
</table>
带
alphanumeric = alpha & numeric
这将始终返回一个5位数字