我正在尝试根据得分将数字更改为'p'或'f'。
不确定如何添加图像,因此这里是一个链接
https://drive.google.com/file/d/1dKn9mkJa9brZXq2tHz8_ULkgreWsBkTI/view?usp=sharing
我已经从字符串中删除了%符号,但是现在我需要根据分数更改数字。 > = 70等于'p',69等于'f'
Sub PassOrFail()
Dim myValue As String
myValue = ThisWorkbook.ActiveSheet.Range("testScore").Value
myValue = Replace(myValue, "%", "")
MsgBox myValue
End Sub
期望显示“略读”:p,MP:f
答案 0 :(得分:0)
这是您需要的吗?
if cInt(myValue) >=70 then
myValue="p"
elseif cInt(myValue><69 then
myValue="f"
end if
谢谢
答案 1 :(得分:0)
在下面尝试此代码:
Sub PassOrFail()
Dim myValue As String
myValue = ThisWorkbook.ActiveSheet.Range("testScore").Value
'String manipulation starts here
'1. Get the pattern position
Dim skim_pos As Integer, mp_pos As Integer
skim_pos = InStr(myValue, "Skim: ")
mp_pos = InStr(myValue, ";MP: ")
'2. Get the skim score
Dim skim As String
skim = Replace(Mid(myValue, skim_pos + 6, mp_pos - (skim_pos + 6)), "%", "")
'3. Get the MP
Dim mp As String
mp = Replace(Mid(myValue, mp_pos + 5, Len(myValue) - (my_pos + 5)), "%", "")
If CInt(skim) >= 70 Then
skim = "p"
Else
skim = "f"
End If
If CInt(mp) >= 70 Then
mp = "p"
Else
mp = "f"
End If
MsgBox "Skim: " & skim & ", MP: " & mp
End Sub
答案 2 :(得分:0)
虽然不是最优雅的解决方案,但它基于给定的细节起作用:
<?xml version="1.0" encoding="UTF-8"?>
<?import com.gluonhq.maps.MapView?>
<MapView xmlns="http://javafx.com/javafx/8.0.172-ea"
xmlns:fx="http://javafx.com/fxml/1"
fx:id="gridMap"
fx:controller="edu.ie3.controller.gridTab.gridMap.GridMapController">
</MapView>
答案 3 :(得分:0)
不是基于“ Skim”或“ MP”而是基于%符号的解决方案:
Sub tst()
Dim mystring As String, y As Variant, i As Long
mystring = ThisWorkbook.ActiveSheet.Range("testScore")
y = Split(mystring, " ")
For i = 1 To UBound(y)
If InStr(y(i), "%") > 0 Then
If Val(Split(Split(y(i), " ")(0), "%")(0)) < 70 Then
mystring = Replace(mystring, Split(Split(y(i), " ")(0), "%")(0) & "%", "f")
Else
mystring = Replace(mystring, Split(Split(y(i), " ")(0), "%")(0) & "%", "p")
End If
End If
Next i
MsgBox mystring
End Sub